Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion PyStatistics/Lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,57 @@ def StandardDeviation(Data: list[WeightedNumber, Fraction, Decimal, int, float]
def MeanAbsoluteDeviation(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> float:
Data = __ConvertData(Data)
mean = Mean(Data)
return round((sum([abs(i - mean) for i in Data]) / len(Data)), 2)
return sum([abs(i - mean) for i in Data]) / len(Data)



def AverageIncrease(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> float:
Data = __ConvertData(Data)
Data = [(Data[i + 1] - Data[i]) for i in range(len(Data) - 1)]
return round((sum(Data) / len(Data)), 2)



def AverageMultiplication(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> float:
Data = __ConvertData(Data)
Data = [(Data[i + 1] / Data[i]) for i in range(len(Data) - 1)]
return round((sum(Data) / len(Data)), 2)



def AverageIncreaseInterpolation(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> list:
Data = __ConvertData(Data)

ai = AverageIncrease(Data) / 2.0

Data = [[Data[i], Data[i] + ai] for i in range(len(Data))]
return [float(i) for e in Data for i in e][:-1]



def AverageMultiplicationInterpolation(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> list:
Data = __ConvertData(Data)

am = AverageMultiplication(Data) / 2.0
Data = [[Data[i], Data[i] * am] for i in range(len(Data))]
return [round(float(i), 2) for e in Data for i in e][:-1]



def PointIncreaseInterpolation(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> list:
Data = __ConvertData(Data) + [0]

Differences = [((Data[i + 1] - Data[i]) / 2) for i in range(len(Data) - 1)]

Data = [[Data[i], Data[i] + Differences[i]] for i in range(len(Differences))]
return [round(float(i), 2) for e in Data for i in e][:-1]



def PointMultiplicationInterpolation(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> list:
Data = __ConvertData(Data) + [0]

Multipliers = [((Data[i + 1] / Data[i]) / 2) for i in range(len(Data) - 1)]

Data = [[Data[i], Data[i] * Multipliers[i]] for i in range(len(Multipliers))]
return [round(float(i), 2) for e in Data for i in e][:-1]
27 changes: 18 additions & 9 deletions README.md
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation for Lists needs use cases for Variance, StandardDeviation, MeanAbsoluteDeviation, AverageIncrease, AverageMultiplication, AverageIncreaseInterpolation, AverageMultiplicationInterpolation, PointIncreaseInterpolation, and PointMultiplicationInterpolation.

Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,24 @@ StandardDeviation(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tu

MeanAbsoluteDeviation(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> float
# Returns the MAD (mean absolute deviation) (the average distance between each number and the mean) of a given list (or tuple) of numbers.

AverageIncrease(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> float
# Returns the AI (average increase) (the average amount each value is increased) of a given list (or tuple) of numbers.

AverageMultiplication(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> float
# Returns the AM (average multiplication) (the average amount each value is multiplied) of a given list (or tuple) of numbers.

AverageIncreaseInterpolation(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> list
# Returns an interpolation (estimating other potential values of a list of numbers) of a given list (or tuple) of numbers by using the AI (average increase) of the list (or tuple).

AverageMultiplicationInterpolation(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> list
# Returns an interpolation (estimating other potential values of a list of numbers) of a given list (or tuple) of numbers by using the AM (average multiplication) of the list (or tuple).

PointIncreaseInterpolation(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> list
# Returns an interpolation (estimating other potential values of a list of numbers) of a given list (or tuple) of numbers by using the mean of each number and the number after.

PointMultiplicationInterpolation(Data: list[WeightedNumber, Fraction, Decimal, int, float] | tuple[WeightedNumber, Fraction, Decimal, int, float]) -> list
# Returns an interpolation (estimating other potential values of a list of numbers) of a given list (or tuple) of numbers by using the AM (average multiplication) of each number and the number after.
```
```py
Data = [43, 321, 912, 213, 213, 9, 34843]
Expand Down Expand Up @@ -408,15 +426,6 @@ print(Range(Data))

print(Outliers(Data))
# Result: [34843]

print(Variance(Data))
# Result: 170696185.67

print(StandardDeviation(Data))
# Result: 13065.08

print(MeanAbsoluteDeviation(Data))
# Result: 8463.14
```
<br />
Expand Down