# my net house

WAHEGURU….!

## Things to Compelte this Week!!

Vanila Implementation of Python and Data-Modeling in Financial markets.

Python LInked-lists.

Python Stacks and Queues.

Python BinarySearch Trees.

Python HashTables.

## hacker’s guide to Traefik Edge Router

Service Discovery:

• Auto Detection of New instances of Service.
• By Default Load balancing is using Round-Robin, Weighted Round Robin, Custom Options are available based on Creativity.
• Available insights in UI (Routes/Services/Middlewares).
• Just like an edge router, we expose a port on the machine where it’s running, and all the inbound traffic goes through it.
• *Priority: One can assign priority to services, and all the load will be distributed to them based on priority. This isn’t mentioned in load-balancing strategies though.
• Provides Request Mirroring
• Only Round Robin Load Balancing is Supported on *Servers*
• Weighted Round Robin on *Services*

Default Dash-Board

InBuilt Authentication,Http Connection handling(timeout and etc) For EntryPoints and MiddleWares.

More UI Features:

• Entrypoints hits (success/failure etc..)
• HTTP Endpoints(Routers, Services, Middlewares) hits
• TCP(Routers, Services) hits

Configuration For EntryPoints and Routers

• Dynamic Configuration on the level of Strat-up and Runtime: (Hot Reloaded)

Consul Example:

[providers.consul]

endpoints = [“127.0.0.1:8500”]

rootKey = “traefik”

ETCD example:

[providers.etcd]

endpoints = [“127.0.0.1:2379”]

rootKey = “traefik”

Full Path Details for Keys and Values

Routers:

Entry Points talks to Routes to Call out Service Functions/Routes.

*Full Regex Support with && || conditions

* Priority Can be assigned to Each Route.

[http.routers]

[http.routers.Router-1]

rule = “HostRegexp(.*\.traefik\.com)”

# …

[http.routers.Router-2]

rule = “Host(foobar.traefik.com)”

Available Configuration Options:

https://docs.traefik.io/routing/providers/kv/

Health Checks:

It keeps doing health checkups of services, and are considered alive as long as they reply back with 2xx, 3xx HTTP codes

Mirroring:

• Able to mirror requests to other services.
• Whole request is buffered in memory until it is mirrored.

## RUN Timescale after HUGE efforts

My Docker command:

docker run -d --name timescaledbworks -p 5000:5432 -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test -e POSTGRES_DB=test timescale/timescaledb:latest-pg11

my GoLnag Source:

 package main import ( "database/sql" _ "github.com/lib/pq" "fmt" ) func main() { var err error // test without port thing connStr := "user=test dbname=test password=test host=0.0.0.0 sslmode=disable port=5000" db, err := sql.Open("postgres", connStr) if err != nil { fmt.Println("could not connecet to Daatabase") } fmt.Println(db) if err := db.Ping(); err != nil { fmt.Println("unable to ping DB : " + err.Error()) return } //else{ //fmt.Println("able to connecet to db") //} 

//db.Query("CREATE TABLE conditions(time TIMESTAMP NOT NULL,location TEXT NOT NULL,temperature DOUBLE PRECISION NULL,humidity DOUBLE PRECISION NULL);") //db.Query("CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;") //db.Query("CREATE TABLE hello") //db.Query("SELECT create_hypertable('conditions','time','location',4);") } 

## Some Gitty GITs

When you don’t want to type username an password each time or when you are not allowed to do so as well.

Your repo should look like this:

git@github.com:USERNAME/REPOSITORY.git


you can see config using:

 nano .git/config 

SSH key can be generated like:

ssh-keygen -t rsa -b 4096 -C “arshpreet.singh@myemail.com”

More about Git and adding ssh key can be found here:
https://help.github.com/articles/connecting-to-github-with-ssh/

## Click – Command Line Interface Creation Kit , OH yeahh Python

This is an Easy to do things in python so we can run scripts using command line Arguments for us as well.


import click

@click.command()
@click.option('--count',default = 1, )
@click.option('--name',prompt = "What you are supposed to do here?")
def test_click(count,name):
for i in range(count):
click.echo(str(name))
'''
How to run this script:

python test_click.py --name "Arsh" --count 4

'''


## Python Send SMS all over the things

This is Python Script that you can use to send Messages on any Phone without leaving trace of any number.


# python script for sending message update

import time
from time import sleep
from sinchsms import SinchSMS

# function for sending SMS
def sendSMS():

# enter all the details
# get app_key and app_secret by registering
# a app on sinchSMS
number = '+919915959387'
app_key = '29d0e101-e619-4226-823a-c39c4b99b5ac'
app_secret = '1WkUjJ3RWEy1P9h9mw/2sQ=='

# enter the message to be sent
message = "hello"

client = SinchSMS(app_key, app_secret)
print("Sending '%s' to %s" % (message, number))

response = client.send_message(number, message)
message_id = response['messageId']
response = client.check_status(message_id)

# keep trying unless the status retured is Successful
while response['status'] != 'Successful':
print(response['status'])
time.sleep(1)
response = client.check_status(message_id)

print(response['status'])

if __name__ == "__main__":
sendSMS()



## Deploy Micro-service in Seconds Using Falcon

Falcon framework is great when you have to build micro-services in Python, All we need to do is create a Class that would provide the specific Purpose to Establish one Micro-service as Route and add the route to the API would be able to server as deploy multiple modes inside the Falcon Architecture as well.


# sample.py

import falcon

class QuoteResource:
def on_get(self, req, resp):
"""Handles GET requests"""
quote = {
'quote': (
"I've always been more interested in "
"the future than in the past."
),
'author': 'Grace Hopper'
}

resp.media = quote
class HelpObject:
def on_get(self, req, resp):
"""Handles GET requests"""
quote = {
'quote': (
"I've always been more interested in "
"the future than in the past."
),
'author': 'Arshpreet Singh'
}

resp.media = quote

api = falcon.API()
api.add_route('/quote', QuoteResource())
api.add_route('/quote2', HelpObject())
<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;">&#65279;</span>


## IBM hyper ledger Business Card creation and Code familiarity [inbetween]

model/*.cto file- This file is able to describe Asset, Participant and Transactions those occur at that business network as well .

• Namespace
• Resources
• Imports from other namespaces, as required

If your model is very large, you can have multiple .cto model files, as necessary. Every .cto model file must include a single namespace and at least one resource definition.

NameSpace: NameSpace is just naming convention for the File-System. For each of your .cto file namespace would be an unique name for the file. Each of the resources available in the file would be taken from that namespace.

Resource: Now we have following kind of resources we can use.

Asset: A business network Asset(Example Bit-coin is an Asset in Bit-coin-Network)

Transaction: A business Logic

Participant: A business network Participant

Event: Notification of something happening in the network

Enumerated Type: A set of named Values

Concept: Any object you want to model that is not one of the other types

Each resource type corresponds to its model type of the same name (for example, asset is used to model an Asset, participant models a Participant, etc.)

asset Vehicle identified by vehicle_id {

}

## Learning Dataframes in Julia

Week4_DataF

### Week 4 – Working with Distributions and DataFrames.¶

In [1]:
# Import the required packages
using Distributions, DataFrames

In [2]:
# Seed the random number generator
srand(1234);

In [3]:
# Question 4: Create the 3 x 30 array named array_1
# 30 rows and 3 columns array
array_1 = [rand(30) rand(30) rand(30)]
size(array_1)
array_1

Out[3]:
30×3 Array{Float64,2}:
0.590845   0.931115   0.643704
0.766797   0.438939   0.401421
0.566237   0.246862   0.525057
0.460085   0.0118196  0.61201
0.794026   0.0460428  0.432577
0.854147   0.496169   0.082207
0.200586   0.732      0.199058
0.298614   0.299058   0.576082
0.246837   0.449182   0.218177
0.579672   0.875096   0.362036
0.648882   0.0462887  0.204728
0.0109059  0.698356   0.932984
0.066423   0.365109   0.827263
⋮
0.0566425  0.404953   0.0396356
0.842714   0.499531   0.79041
0.950498   0.658815   0.431188
0.96467    0.515627   0.137658
0.945775   0.260715   0.60808
0.789904   0.59552    0.255054
0.82116    0.292462   0.498734
0.0341601  0.28858    0.0940369
0.0945445  0.61816    0.52509
0.314926   0.66426    0.265511
0.12781    0.753508   0.110096
0.374187   0.0368842  0.834362
In [4]:
# Question 5: Mean and variance of column 1
mean_column_1 = mean(array_1[:,1])
var_column_1=var(array_1[:,1])
println("mean=",mean_column_1)
println("var=",var_column_1)

mean=0.5014887976938368
var=0.10653465363277906

In [5]:
# Question 5 (continued): Mean and variance of column 2
mean_column_2 = mean(array_1[:,2])
var_column_2=var(array_1[:,2])
println("mean=",mean_column_2)
println("var=",var_column_2)

mean=0.4160447968360426
var=0.06360439983290869

In [6]:
# Question 5 (continued): Mean and variance of column 3
mean_column_3 = mean(array_1[:,3])
var_column_3=var(array_1[:,3])
println("mean=",mean_column_3)
println("var=",var_column_3)

mean=0.4372634519427959
var=0.07568707224628725

In [7]:
# Question 6: Import array_1 into a DataFrame named df
df = DataFrame(array_1)

Out[7]:
x1 x2 x3
1 0.5908446386657102 0.9311151512445586 0.6437042811826996
2 0.7667970365022592 0.43893895933102156 0.40142056533714965
3 0.5662374165061859 0.24686248047491066 0.5250572942486489
4 0.4600853424625171 0.011819583479107054 0.6120098074984683
5 0.7940257103317943 0.046042826396498704 0.43257652982765626
6 0.8541465903790502 0.496168672722459 0.0822070287962946
7 0.20058603493384108 0.7320003814997245 0.19905799020907944
8 0.2986142783434118 0.29905752670238184 0.5760819730593403
9 0.24683718661000897 0.4491821088563024 0.21817706596841413
10 0.5796722333690416 0.8750962647851142 0.3620355262053865
11 0.6488819502093455 0.046288741031345504 0.20472832290217324
12 0.010905889635595356 0.6983555060532487 0.93298350850828
13 0.06642303695533736 0.3651093677271471 0.8272627957034728
14 0.9567533636029237 0.3024777928234499 0.09929915955881308
15 0.646690981531646 0.3725754415996787 0.6342997886044144
16 0.11248587118714015 0.15050782744925795 0.1327153585755645
17 0.2760209506672211 0.14732938279328955 0.7751941503856596
18 0.6516642063795697 0.2834013103457036 0.8692366891234362
19 0.05664246860321187 0.40495283364883794 0.039635617270926904
20 0.8427136165865521 0.49953074411487797 0.7904095314876494
21 0.9504984071553011 0.6588147837334961 0.43118828904466633
22 0.9646697763820897 0.5156272179795256 0.1376583132625555
23 0.9457754052519123 0.26071522632820776 0.6080803126880718
24 0.7899036826169576 0.5955204840509289 0.2550540600167448
25 0.8211604203482923 0.2924615242315285 0.4987340031883092
26 0.03416010848943718 0.2885798506061561 0.09403688346569439
27 0.09454448946400307 0.6181597973815087 0.5250899072103514
28 0.31492622391998415 0.6642598175011505 0.2655109248498748
29 0.12780989889368866 0.7535081177709988 0.11009621399607639
30 0.374186714831074 0.03688418241886171 0.8343616661080064
In [8]:
# check available names and fieldnames in Julia, Python's alternative
f_name =fieldnames(df)
name=names(df)
println(f_name,name)

Symbol[:columns, :colindex]Symbol[:x1, :x2, :x3]

In [9]:
# Accessing different columns of df
df[:x3]

Out[9]:
30-element Array{Float64,1}:
0.643704
0.401421
0.525057
0.61201
0.432577
0.082207
0.199058
0.576082
0.218177
0.362036
0.204728
0.932984
0.827263
⋮
0.0396356
0.79041
0.431188
0.137658
0.60808
0.255054
0.498734
0.0940369
0.52509
0.265511
0.110096
0.834362
In [10]:
# Question 7: Change the names of the columns to Var1, Var2, and Var3
rename!(df,Dict(:x1=>:Var1,:x2=>:Var2,:x3=>:Var))

Out[10]:
Var1 Var2 Var
1 0.5908446386657102 0.9311151512445586 0.6437042811826996
2 0.7667970365022592 0.43893895933102156 0.40142056533714965
3 0.5662374165061859 0.24686248047491066 0.5250572942486489
4 0.4600853424625171 0.011819583479107054 0.6120098074984683
5 0.7940257103317943 0.046042826396498704 0.43257652982765626
6 0.8541465903790502 0.496168672722459 0.0822070287962946
7 0.20058603493384108 0.7320003814997245 0.19905799020907944
8 0.2986142783434118 0.29905752670238184 0.5760819730593403
9 0.24683718661000897 0.4491821088563024 0.21817706596841413
10 0.5796722333690416 0.8750962647851142 0.3620355262053865
11 0.6488819502093455 0.046288741031345504 0.20472832290217324
12 0.010905889635595356 0.6983555060532487 0.93298350850828
13 0.06642303695533736 0.3651093677271471 0.8272627957034728
14 0.9567533636029237 0.3024777928234499 0.09929915955881308
15 0.646690981531646 0.3725754415996787 0.6342997886044144
16 0.11248587118714015 0.15050782744925795 0.1327153585755645
17 0.2760209506672211 0.14732938279328955 0.7751941503856596
18 0.6516642063795697 0.2834013103457036 0.8692366891234362
19 0.05664246860321187 0.40495283364883794 0.039635617270926904
20 0.8427136165865521 0.49953074411487797 0.7904095314876494
21 0.9504984071553011 0.6588147837334961 0.43118828904466633
22 0.9646697763820897 0.5156272179795256 0.1376583132625555
23 0.9457754052519123 0.26071522632820776 0.6080803126880718
24 0.7899036826169576 0.5955204840509289 0.2550540600167448
25 0.8211604203482923 0.2924615242315285 0.4987340031883092
26 0.03416010848943718 0.2885798506061561 0.09403688346569439
27 0.09454448946400307 0.6181597973815087 0.5250899072103514
28 0.31492622391998415 0.6642598175011505 0.2655109248498748
29 0.12780989889368866 0.7535081177709988 0.11009621399607639
30 0.374186714831074 0.03688418241886171 0.8343616661080064
In [11]:
### we can also tail function see last required entries
tail(df,20)

Out[11]:
Var1 Var2 Var
1 0.6488819502093455 0.046288741031345504 0.20472832290217324
2 0.010905889635595356 0.6983555060532487 0.93298350850828
3 0.06642303695533736 0.3651093677271471 0.8272627957034728
4 0.9567533636029237 0.3024777928234499 0.09929915955881308
5 0.646690981531646 0.3725754415996787 0.6342997886044144
6 0.11248587118714015 0.15050782744925795 0.1327153585755645
7 0.2760209506672211 0.14732938279328955 0.7751941503856596
8 0.6516642063795697 0.2834013103457036 0.8692366891234362
9 0.05664246860321187 0.40495283364883794 0.039635617270926904
10 0.8427136165865521 0.49953074411487797 0.7904095314876494
11 0.9504984071553011 0.6588147837334961 0.43118828904466633
12 0.9646697763820897 0.5156272179795256 0.1376583132625555
13 0.9457754052519123 0.26071522632820776 0.6080803126880718
14 0.7899036826169576 0.5955204840509289 0.2550540600167448
15 0.8211604203482923 0.2924615242315285 0.4987340031883092
16 0.03416010848943718 0.2885798506061561 0.09403688346569439
17 0.09454448946400307 0.6181597973815087 0.5250899072103514
18 0.31492622391998415 0.6642598175011505 0.2655109248498748
19 0.12780989889368866 0.7535081177709988 0.11009621399607639
20 0.374186714831074 0.03688418241886171 0.8343616661080064
In [12]:
# Creatring Second DataFrame
df2=DataFrame(tail(df,20))

Out[12]:
Var1 Var2 Var
1 0.6488819502093455 0.046288741031345504 0.20472832290217324
2 0.010905889635595356 0.6983555060532487 0.93298350850828
3 0.06642303695533736 0.3651093677271471 0.8272627957034728
4 0.9567533636029237 0.3024777928234499 0.09929915955881308
5 0.646690981531646 0.3725754415996787 0.6342997886044144
6 0.11248587118714015 0.15050782744925795 0.1327153585755645
7 0.2760209506672211 0.14732938279328955 0.7751941503856596
8 0.6516642063795697 0.2834013103457036 0.8692366891234362
9 0.05664246860321187 0.40495283364883794 0.039635617270926904
10 0.8427136165865521 0.49953074411487797 0.7904095314876494
11 0.9504984071553011 0.6588147837334961 0.43118828904466633
12 0.9646697763820897 0.5156272179795256 0.1376583132625555
13 0.9457754052519123 0.26071522632820776 0.6080803126880718
14 0.7899036826169576 0.5955204840509289 0.2550540600167448
15 0.8211604203482923 0.2924615242315285 0.4987340031883092
16 0.03416010848943718 0.2885798506061561 0.09403688346569439
17 0.09454448946400307 0.6181597973815087 0.5250899072103514
18 0.31492622391998415 0.6642598175011505 0.2655109248498748
19 0.12780989889368866 0.7535081177709988 0.11009621399607639
20 0.374186714831074 0.03688418241886171 0.8343616661080064
In [13]:
# Question 9: Calculate simple descriptive statistics of all the columns in df2 using the describe() function
describe(df2)

Var1
Summary Stats:
Mean:           0.484341
Minimum:        0.010906
1st Quartile:   0.108001
Median:         0.510439
3rd Quartile:   0.826549
Maximum:        0.964670
Length:         20
Type:           Float64

Var2
Summary Stats:
Mean:           0.397753
Minimum:        0.036884
1st Quartile:   0.277730
Median:         0.368842
3rd Quartile:   0.601180
Maximum:        0.753508
Length:         20
Type:           Float64

Var
Summary Stats:
Mean:           0.453279
Minimum:        0.039636
1st Quartile:   0.136423
Median:         0.464961
3rd Quartile:   0.778998
Maximum:        0.932984
Length:         20
Type:           Float64


In [14]:
# Question 10: Add a column to df2 named Cat1 to df2 consisting of randomly selecting either the strings GroupA or GroupB
df2 = hcat(df2, rand(["GroupA","GroupB"],20))
rename!(df2,Dict(:x1=>:Cat1))

Out[14]:
Var1 Var2 Var Cat1
1 0.6488819502093455 0.046288741031345504 0.20472832290217324 GroupB
2 0.010905889635595356 0.6983555060532487 0.93298350850828 GroupB
3 0.06642303695533736 0.3651093677271471 0.8272627957034728 GroupA
4 0.9567533636029237 0.3024777928234499 0.09929915955881308 GroupA
5 0.646690981531646 0.3725754415996787 0.6342997886044144 GroupA
6 0.11248587118714015 0.15050782744925795 0.1327153585755645 GroupA
7 0.2760209506672211 0.14732938279328955 0.7751941503856596 GroupB
8 0.6516642063795697 0.2834013103457036 0.8692366891234362 GroupB
9 0.05664246860321187 0.40495283364883794 0.039635617270926904 GroupB
10 0.8427136165865521 0.49953074411487797 0.7904095314876494 GroupB
11 0.9504984071553011 0.6588147837334961 0.43118828904466633 GroupA
12 0.9646697763820897 0.5156272179795256 0.1376583132625555 GroupB
13 0.9457754052519123 0.26071522632820776 0.6080803126880718 GroupA
14 0.7899036826169576 0.5955204840509289 0.2550540600167448 GroupB
15 0.8211604203482923 0.2924615242315285 0.4987340031883092 GroupA
16 0.03416010848943718 0.2885798506061561 0.09403688346569439 GroupB
17 0.09454448946400307 0.6181597973815087 0.5250899072103514 GroupB
18 0.31492622391998415 0.6642598175011505 0.2655109248498748 GroupA
19 0.12780989889368866 0.7535081177709988 0.11009621399607639 GroupA
20 0.374186714831074 0.03688418241886171 0.8343616661080064 GroupA
In [15]:
# Question 11: Create a new DataFrame named df3
df3 = DataFrame(A=1:20,B=21:40,C=41:60)

Out[15]:
A B C
1 1 21 41
2 2 22 42
3 3 23 43
4 4 24 44
5 5 25 45
6 6 26 46
7 7 27 47
8 8 28 48
9 9 29 49
10 10 30 50
11 11 31 51
12 12 32 52
13 13 33 53
14 14 34 54
15 15 35 55
16 16 36 56
17 17 37 57
18 18 38 58
19 19 39 59
20 20 40 60
In [16]:
# Question 12: Change indicated values to empty entries
#In a code cells below, change the values in df3 of the following cells to NA: row 10, column 1, row 15, column 2 and row #19, column 3
df3[10,1] = NA
df3[15,2] = NA
df3[19,3] = NA
df3

Out[16]:
A B C
1 1 21 41
2 2 22 42
3 3 23 43
4 4 24 44
5 5 25 45
6 6 26 46
7 7 27 47
8 8 28 48
9 9 29 49
10 NA 30 50
11 11 31 51
12 12 32 52
13 13 33 53
14 14 34 54
15 15 NA 55
16 16 36 56
17 17 37 57
18 18 38 58
19 19 39 NA
20 20 40 60
In [17]:
# Question 13: Create DataFrame df4 that contains no rows with NaN (NA) values
df4 = completecases!(df3)

Out[17]:
A B C
1 1 21 41
2 2 22 42
3 3 23 43
4 4 24 44
5 5 25 45
6 6 26 46
7 7 27 47
8 8 28 48
9 9 29 49
10 11 31 51
11 12 32 52
12 13 33 53
13 14 34 54
14 16 36 56
15 17 37 57
16 18 38 58
17 20 40 60

## Some Plugs-Plays with Julia Programing

Week3_PR_Template

# Title: Week 3 – Fitting a Curve¶

In [17]:
# Initilization of Plots Package
using Plots
pyplot()

Out[17]:
Plots.PyPlotBackend()

### Reading data from given Sample file¶

In [18]:
data_tofit = readdlm("Week3_PR_Data.dat", '\t', header=true)
typeof(data_tofit)

Out[18]:
Tuple{Array{Float64,2},Array{AbstractString,2}}

### Using For loop to print data in array¶

In [19]:
new_array=data_tofit[1]
for i in 1:size(new_array)[1]
println(new_array[i,:])
end

[0.501309, -0.977698]
[1.52801, 0.527711]
[1.70012, 1.71152]
[1.99249, 1.891]
[2.70608, -0.463428]
[2.99493, -0.443567]
[3.49185, -1.27518]
[3.50119, -0.6905]
[4.45992, -5.51613]
[4.93697, -6.0017]
[5.02329, -8.36417]
[5.04234, -7.92448]
[5.50739, -10.7748]
[5.56867, -10.9172]


### Scatter plot¶

In [20]:
# Create the arrays x and y, assigning x the first column of data_tofit and y the second column
x,y = new_array[:,1],new_array[:,2]
scatter(x,y)

Out[20]:

### Creating parabfit() one-liner function¶

In [21]:
# Create a function called parabfit, with x as the argument, returning a*x^2 + b*x + c
parabfit(x)=a*x^2 + b*x + c

Out[21]:
parabfit (generic function with 1 method)

### Ploting against Default values of a,b and c¶

In [22]:
a = 1
b = 1
c = 1

plot(parabfit,-2,2)

Out[22]:

### Ploting using different range for parabfit()¶

In [23]:
# Create variables a, b and c, assigning each the value 1
a = 1
b = 1
c = 1

# Plot the function parabfit, for x values between -5 and 5
plot(parabfit,-5,5)

Out[23]:
In [24]:
# More plot!() tries.
a,b,c = 1,1,1
scatter(x_axis,y_axis)
plot!(parabfit,-5,5)

UndefVarError: x_axis not defined

Stacktrace:
[1] include_string(::String, ::String) at ./loading.jl:515

Optimize parameters a, b and c such that it fits the data points more concisely.

1. Parbola should be downwards that detarmines cofficient a must be negative.
2. As from the data points value of cofficient c should be close to zero.
3. Cofficient b determines the values of y axis that must be possitive.
In [25]:
# More plot!() tries.
a,b,c = -1,2,3
scatter(x,y)
plot!(parabfit,-5,5)

Out[25]:
In [26]:
# More plot!() tries.
a,b,c = -1,0.1,2
scatter(x_axis,y_axis)
plot!(parabfit,-5,5)

UndefVarError: x_axis not defined

Stacktrace:
[1] include_string(::String, ::String) at ./loading.jl:515
In [27]:
# More plot!() tries.
a,b,c = -1,0.8,3
scatter(x,y)
plot!(parabfit,-5,5)

Out[27]:
In [28]:
# More plot!() tries.
a,b,c = -0.9,2.7,0.05
scatter(x,y)
plot!(parabfit,-5,5)

Out[28]:

### Optimising variable c¶

In [29]:
a,b = 1,1
plot(scatter(x,y,alpha=0.5))
c=0
plot!(parabfit,-5,5)
c = -1
plot!(parabfit,-5,5)
c = -2
plot!(parabfit,-5,5)
c = -3
plot!(parabfit,-5,5)
c = -4
plot!(parabfit,-5,5)
c = -5
plot!(parabfit,-5,5)
c = 2
plot!(parabfit,-5,5)

Out[29]:

### Optimising Variable a¶

In [31]:
c,b = 1,1
plot(scatter(x,y,alpha=0.5))
a=0
plot!(parabfit,0,5)
a = -1
plot!(parabfit,0,5)
a = -2
plot!(parabfit,0,5)
a = -3
plot!(parabfit,0,5)
a = -4
plot!(parabfit,0,5)
a = -5
plot!(parabfit,0,5)
a = 2
plot!(parabfit,0,5)

Out[31]:
In [37]:
#Locating final value for a
c,b = 3,1
plot(scatter(x,y,alpha=0.5))
a = -1
plot!(parabfit,0,5)

Out[37]:

### Optimising for b¶

In [53]:
c,a = 2,-1
plot(scatter(x,y,alpha=0.5))
b=0
plot!(parabfit,0,5)
b = 1
plot!(parabfit,0,5)
b = 2
plot!(parabfit,0,5)
b = 3
plot!(parabfit,0,5)
b = 4
plot!(parabfit,0,5)
b = 5
plot!(parabfit,0,5)
b = -1
plot!(parabfit,0,5)

Out[53]:
In [57]:
# plotting for b=4
c,a = 1,-1
plot(scatter(x,y,alpha=0.5))
b = 3
plot!(parabfit,0,8)

Out[57]:

### final Values of a,b and c¶

In [65]:
# plotting for b=4
c,a,b = 1,-1,3
plot(scatter(x,y,alpha=0.5))
plot!(parabfit,0,5)

Out[65]:

To optimize values of a,b,c we had to plot one variable many times to find out one variable’s occurrence at different levels
of scale. By changing the range of parabola function it was more easy to come up with more accurate values of a,b and c

In [ ]: