def plot_regression(data, line, filename=''):

    plt.plot(data[0], data[1], 'ro')
    plt.plot(line[0], line[1], 'b-', linewidth=3)

    if filename:
        plt.savefig('img/'+ filename +'.png')
    else:
        plt.show()
    plt.clf()
    return


if __name__ == '__main__':

    download_file( PATH + 'linreg.txt')
    data = load('linreg.txt')

    line = SSE_asol(data)
    plot_regression(data, line, filename='analytic_solution_linregtxt')
    line = SSE_grid_search( data, filename='grid_search_linregtxt')


    a = -2
    b =  5
    for distr in [normal, lognormal]:
        print "Generated line $y = {}\cdot x + {}$ with {} distribution.".format(a, b, distr.__name__)
        data = linear_data(n=100,distribution=distr, L=-5, U=50, a=a,b=b, sigma=10)
    
        line = SSE_asol( data )
        plot_regression(data, line, filename='analytic_solution_'+str(distr.__name__))
def plot_regression(data, line, filename=''):

    plt.plot(data[0], data[1], 'ro')
    plt.plot(line[0], line[1], 'b-', linewidth=3)

    if filename:
        plt.savefig('img/' + filename + '.png')
    else:
        plt.show()
    plt.clf()
    return


if __name__ == '__main__':

    download_file(PATH + 'linreg.txt')
    data = load('linreg.txt')

    line = SSE_asol(data)
    plot_regression(data, line, filename='analytic_solution_linregtxt')
    line = SSE_grid_search(data, filename='grid_search_linregtxt')

    a = -2
    b = 5
    for distr in [normal, lognormal]:
        print "Generated line $y = {}\cdot x + {}$ with {} distribution.".format(
            a, b, distr.__name__)
        data = linear_data(n=100,
                           distribution=distr,
                           L=-5,
                           U=50,
        return

    def on_board(self, pos):
        # False if the position pos is of outside the grid

        if any(x < 0 for x in pos) or any(x > self.size - 1 for x in pos):
            return False
        else:
            return True


if __name__ == '__main__':

    # download the file, necessary for server
    download_file(PATH + 'ciselne-bludiste.txt')

    mazes = load_num_maze('ciselne-bludiste.txt', '-')

    for maze in mazes:
        maze = NumberMaze(maze)
        # magic is here
        maze.DFS([0, 0])
        maze.calc_sums()

        # creates animated gif for different paths with
        # lowest and highest sum of "jumps"
        for path in maze.low_paths:
            number_gif_path(maze.maze, maze.size, path, 30, 'low')

        for path in maze.high_paths:
Exemple #4
0


    def on_board(self, pos):
    # False if the position pos is of outside the grid

        if any(x < 0 for x in pos) or any(x > self.size - 1 for x in pos):
            return False
        else:
            return True 


if __name__ == '__main__':

    # download the file, necessary for server
    download_file( PATH + 'ciselne-bludiste.txt')

    mazes = load_num_maze('ciselne-bludiste.txt', '-')


    for maze in mazes:
        maze  = NumberMaze( maze )
        # magic is here
        maze.DFS([0,0])
        maze.calc_sums()

        # creates animated gif for different paths with
        # lowest and highest sum of "jumps"
        for path in maze.low_paths:
            number_gif_path(maze.maze, maze.size, path, 30, 'low')