# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Intro
# ______
#
#
# ### This notebook will be mainly used for the capstone project
#  
#  _____
#  
#  Source: 
#  this notebook will be mainly used for the capstone projecthttps://github.com/allaccountstaken/Coursera_Capstone.git

import pandas as pd
import numpy as np

print("Hello Capstone Project Course!")


class MyClass():
    
    def method(self):
        return print("instance method called, ", self)
    
    @classmethod 
    def class_method(cls):
        return "class method called", cls
    
    @staticmethod
    def static_method():
        return "static method called"


obj = MyClass()

obj.method()

obj.class_method()

obj.static_method()


class Pizza:
    def __init__(self, ingredients):
        self.ingredients = ingredients

    #def __repr__(self):
        #return f'Pizza({self.ingredients!r})'
        
    def __repr__(self):
        return 'Pizza(%r)' % self.ingredients


p = Pizza(['cheese', 'tomatos'])

print(p)

p













# +


class Distribution():
    def __init__(self, mu=0, sigma=1):
        self.mean = mu
        self.stdev = sigma
        self.data = []
    
    def read_data_file(self, file_name):
        with open(file_name) as file:
            data_list = []
            line = file.readline()
            while line:
                data_list.append(int(line))
                line = file.readline()
        file.close()
        self.data = data_list


# +
import math
import matplotlib.pyplot as plt

class Gaussian(Distribution):
    
    def __init__(self, mu=0, sigma=1):
        
        Distribution.__init__(self, mu, sigma)
        
        
    def calculate_mean(self):
        avg = 1.0 * sum(self.data) / len(self.data)
        self.mean = avg
        return self.mean
    def calculate_stdev(self, sample=True):
        if sample:
            n = len(salf.data - 1)
        else:
            n = len(self.data)
        
        mean = self.calculate_mean()
        sigma = 0
        
        for d in self.data:
            sigma += (d - mean) ** 2
        sigma = math.sqrt(sigma / n)
        self.stdev = sigma
        
        return self.stdev
        
    def read_data_file(self, file_name, sample=True):
        with open(file_name) as file:
            data_list = []
            line = file.readline()
            while line:
                data_list.append(int(line))
                line = file.readline()
        file.close()
        self.data = data_list
        self.mean = self.calculate_mean()
        self.stdev = self.calculate_stdev(sample)
    
    def plot_histogram(self):
        plt.hist(self.data)
        plt.title('Histogram of Gaussian Data')
        plt.xlabel('data')
        plt.ylabel('count')
    
    def pdf(self, x):
        return (1.0 / (self.stdev * math.sqrt(2*math.pi))) * math.exp(-0.5*((x - self.mean) / self.stdev) ** 2)
    
    def __add__(self, other):
        
        """Function to add together two Gaussian distributions
        
        Args:
            other (Gaussian): Gaussian instance
            
        Returns:
            Gaussian: Gaussian distribution
            
        """
        
        result = Gaussian()
        result.mean = self.mean + other.mean
        result.stdev = math.sqrt(self.stdev ** 2 + other.stdev ** 2)
        
        return result
        
        
    def __repr__(self):
    
        """Function to output the characteristics of the Gaussian instance
        
        Args:
            None
        
        Returns:
            string: characteristics of the Gaussian
        
        """
        
        return "mean {}, standard deviation {}".format(self.mean, self.stdev)

# +
# initialize two gaussian distributions
gaussian_one = Gaussian(25, 3)
gaussian_two = Gaussian(30, 2)

# initialize a third gaussian distribution reading in a data efile
gaussian_three = Gaussian()
gaussian_three.read_data_file('numbers.txt')
gaussian_three.calculate_mean()
gaussian_three.calculate_stdev()
# -



StarcoderdataJupyterScriptsDedupFiltered