## 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