Posted By

eiger_824 on 11/02/15

assignment

/ Published in: Python

asdfasd

`# -*- coding: utf-8 -*-"""Spyder Editor This is a temporary script file.""" #Assignment 1from __future__ import divisionimport randomfrom scipy import *from math import * #1.1)import numpy as nppoisson_lambda = 4s = np.random.poisson(poisson_lambda,50) #1.2) mean = 0for i in s:    mean = mean + imean = mean/len(s) #<--------- APROX. MEAN mean2 = 0s_square = s**2for i in s_square:    mean2 = mean2 + imean2 = mean2/len(s_square)variance = mean2 - mean**2 #<------ APROX VARIANCE #1.3)print 'Calculated mean: '.__add__(str(mean))print 'Calculated variance: '.__add__(str(variance))print 'Theoretical mean: '.__add__(str(poisson_lambda))print 'Theoretical variance: '.__add__(str(poisson_lambda))#Theoretically, lambda is the value for both the mean and variance of a Poisson# distribution. The fact that the number of observations is not very high #suggests that the approximation calculated in 1.4 won't be very accurate.#If the number of observations was greater, the aproximation would be better #1.4)from collections import Countercnt = Counter()for i in s:    cnt[i] += 1cnt#1.5)import matplotlib.pyplot as pltd = dict(cnt) #from Counter() to dictionaryplt.bar(range(len(d)),d.values())plt.title('Bar plot of frequencies of observed values')plt.xlabel('Observed values')plt.ylabel('Number of occurrences')plt.show()  #1.6)import matplotlib.pyplot as plt2poisson_pmf = [x for x in range(14)] #initialization#I am going to create manually a poisson distribution of 14 elementsfor i in range(14):    poisson_pmf[i] = (((poisson_lambda)**i)*(e**(-poisson_lambda)))/factorial(i)plt2.bar(range(len(poisson_pmf)),poisson_pmf)plt2.title('Bar plot of the poisson distribution between range [0,13]')plt2.xlabel('Observed values')plt2.ylabel('Magnitude')plt2.show() #1.7)from scipy import statsa = stats.ttest_1samp(s,2.0)b = stats.ttest_1samp(s,3.7)c = stats.ttest_1samp(s,4.3)  #Assignment 2#2.1)import numpy as np2X1 = np2.random.exponential(5.0,100)X2= np2.random.exponential(5.0,100)#2.2)Y = [x for x in range(100)]for i in range(100):    if X1[i]*X2[i]<=30+random.normal(0,100):        Y[i] = 'Blue'    else:        Y[i] = 'Orange' #2.3)import matplotlib.pyplot as plt3plt3.scatter(X1,X2,c=Y)plt3.xlabel('X1 values')plt3.ylabel('X2 values')plt3.title('Scatter plot of X1 vs X2')plt3.show() #2.4)X1X2 = zip(X1,X2) #2.5)from sklearn import svm#a)clf = svm.SVC(kernel='linear')clf.fit(X1X2, Y)#b)clf2 = svm.SVC(kernel='rbf', gamma=0.7)clf2.fit(X1X2, Y) #2.6)#For the linear kernel:linear_prediction = clf.predict(X1X2)#For the rbf kernel:rbf_prediction = clf2.predict(X1X2) #2.7)#For the linear kernelimport matplotlib.pyplot as plt4plt4.scatter(X1,X2,c=linear_prediction)plt4.xlabel('X1 values')plt4.ylabel('X2 values')plt4.title('Linearly predicted scatter plot of X1 vs X2')plt4.show()#For the rbf kernel:import matplotlib.pyplot as plt5plt5.scatter(X1,X2,c=rbf_prediction)plt5.xlabel('X1 values')plt5.ylabel('X2 values')plt5.title('RBF-predicted scatter plot of X1 vs X2')plt5.show()`

Posted By: DavidBryant on February 28, 2018

Thanks for the code. Now I will type my essay fast with your help. I have been looking for this peace of code, without that I cannot finish my program.

Posted By: itskate on March 6, 2018

Extremely intriguing book to peruse, I have just perused two books of this Buy an Essay Online. He is better than average at composing, so far his books are among my top choices.

Posted By: richardy on April 11, 2018

Check the reviews of instantassignmenthelp before assignment help.

Posted By: miaryan on April 12, 2018

Hi itskate, can you help me with my essay

Posted By: LukeWright on April 26, 2018

Best one to share! Org

Posted By: ameliahadlock on May 22, 2018

Homework, or a homework task, is an arrangement of errands doled out to understudies by their instructors to be finished outside the class. Normal homework assignments may incorporate required perusing, a composition or writing venture, numerical activities to be finished, data to be explored before a test, or different aptitudes to be rehearsed. vehicle graphics dubai

Posted By: williamlucas on June 22, 2018

Thanks for sharing the code. It work like anything.

Assignment Help

Posted By: Michellejohnson1 on July 9, 2018

Feeling down throughout the week? Is the idea of writing a due project making you cringe? Itâ€™s nothing to feel ashamed of, we have all been there! Dump your project on my homework help programming homework help and forget about it. Maybe go to a barbeque party in the sun to lift yourself up. We all deserve a break sometimes. Comment on this post if you feel the same way.

Posted By: theresadelcas on September 5, 2018

My Assignment Services is a well-established and prominent name in providing high-quality assignment help online to students since almost a decade. You can trust our academic ghostwriters completely to get best quality write-ups including case studies, research proposals, dissertations and theses, and more. It is the best do my assignment provider.Students should always keep themselves ready to meet the university requirements in order to achieve good grades, moreover, they prefer attending lengthy classes instead of writing assignments. Students who are not comfortable with writing assignments can avail university assignment help by myob assignment help at My Assignment Services comparatively low prices.

Posted By: andrewsymond on October 16, 2018

You can rent Singapore expert writers to ensure top quality cheap essay writing service singapore. Singapore is known for a system of quality control before the assignment is delivered. We examine plagiarism on each assignment to ensure that they are 100% literary and error free.

Posted By: jamesstephens on October 17, 2018

The professional report writing help ireland writer at IrelandAssignmentHelp.com is well-versed with all the academic writing styles and format your assignment in any of the styles that students ask for such as MLA, APA, Harvard, Oxford, Chicago, Vancouver or any other.

Posted By: jeniferconnorsmk on October 17, 2018

Being a law student it is very difficult for me to invest a lot of time on other things, so when it comes to writing an assignment it becomes very challenging for me. Writing an assignment is a lot of work. We need to do a lot of research work and also write a lot of pages which is very time-consuming. So, I started searching for help and found the Business law assignment help australia. I was assisted by a professional with the assignment and the assignment that was delivered to me fetched me really good grades. I am highly satisfied with the assistance that was offered to me. Pay Someone To Do Your Assignment australia

Posted By: stefancarl on March 11, 2019

Homework help Leeds is the best assignment services given by students assignment help in all over the world at a very reasonable price. Our professional writers have great knowledge of any subject

Posted By: SahibKumarKhan on March 20, 2019
Posted By: breeboone on June 19, 2019

There is a number of possible solutions to every problem encountered in the business field. Your main objective is to explain why the solution offered in your essay will be the best for problem-solving. When you need to write a good business essay, you need to become a real researcher of the selected issue. In order to do this, there are the best topics to write about.