Skip to content

Commit

Permalink
used autopep8 to fix indentation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin-Furtado committed Nov 1, 2023
1 parent f336414 commit c7f52a2
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions Temperature/math_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,40 @@

## Math equation ##
## KG = Eest / (Eest + Emea) ##
def kalman_gain(error_in_est:float,error_in_mea:float)->float:


def kalman_gain(error_in_est: float, error_in_mea: float) -> float:
'''This function calculates the Kalman gain
input: Error in estimate, Error in measurement
output: Kalman gain
'''
gain = error_in_est/(error_in_est + error_in_mea)
return round(gain,2)
return round(gain, 2)

## Math equation ##
## Current Estimate = Previous extimate + KG[measurement - previous estimate] ##
def current_estimate(previous_est:float,
measurement:float,
kalmangain:float)->float:
'''
This function calcuates the current esitmate for the kalman filter
input: previous estimate, currrent measurement, kalman gain
output: current estimate
'''
residual = measurement - previous_est
weighted_residue = kalmangain * residual
return round((previous_est + weighted_residue),2)


def current_estimate(previous_est: float,
measurement: float,
kalmangain: float) -> float:
'''
This function calcuates the current esitmate for the kalman filter
input: previous estimate, currrent measurement, kalman gain
output: current estimate
'''
residual = measurement - previous_est
weighted_residue = kalmangain * residual
return round((previous_est + weighted_residue), 2)

## Math equation ##
## Error in current estimate = [1 - KG] x error in previous estimate ##
def error_in_estimate(kalmangain:float,error_previous_est:float)->float:


def error_in_estimate(kalmangain: float, error_previous_est: float) -> float:
'''
Calulates the error in current estimate
input: Kalman Gain, Error in previous estimate
output: Error in current estimate
'''
return round((1-kalmangain)*error_previous_est,2)
return round((1-kalmangain)*error_previous_est, 2)

0 comments on commit c7f52a2

Please sign in to comment.