solutions for assignment1
Assignment 1
数据结构与算法分析(2017年秋季学期),Assignment #1截止日期:2017年9月21日星期四姓名:________________ 学号:___________________ 班级:_______________在答题之前,请仔细阅读以下注意事项:(1)请独立完成作业。
(2)本作业包含五个大题,请用英语简单明确作答。
(3)请于截止日期前将作业纸质版本交给本班学习委员,学习委员在9月21日星期四上课开始前将作业集中交给我。
(4)请务必按时提交作业,从9月21日10点40分开始计时,迟交24小时内作业总分扣30%,迟交24小时之后,该次作业计0分。
1.Define an ADT for a set of integers (remember that a set may not contain duplicates). Your ADTshould contain the following seven operations:a)Insert: insert an integer into a set;b)Delete: remove an integer from a set;c)Size: return the size of a set currently;d)Empty: return if a set is empty;e)Union: return the union of two sets;f)Intersection: return the intersection of two sets;g)SetDifference: return the difference of two sets.Each operation should be clearly defined in terms of its input and output.2.State whether each of the following relations is a partial ordering, and explain why or why not.a)“isFatherOf” on the set of people.b)“isOlderThan” on the set of people.c)“noLessThan” on the set of integers.d){(a,b),(a,a),(b,a)} on the set of {a,b}.e){(2,1),(1,3),(2,3)} on the set of {1,2,3}.3.Answer the following two questions.a)Prove that x log a y = y log a x for any a > 0, x > 0, and y > 0.b)Derive the closed form of the recurrence relation: f(n) = 2 f(n/2) + 2n, with f(1) = 1.To simplify the problem, you may assume that n is a power of 2. That is, the relation holds for n = 2t for some non-negative integer t.4.For each pair of the following functions, determine whether f(n) is in O(g(n)), f(n)is in Ω(g(n)),or f(n) = Θ(g(n)).a)f(n) = log(n2); g(n) = log n + 7b)f(n) = log(n2); g(n) = √nc)f(n) = log n; g(n) = n log n + nd)f(n) = n; g(n) = (log n)25.Let P be an array storing integers.a)Write in pseudocode an algorithm to find a sub-array of P with the largest sum. That is, youralgorithm takes as input an array P, its size n, and returns two array indexes i and j with i≤j, such that the sum: P[i]+P[i+1]+...+P[j−1]+P[j] is as large as possible.For example, if P={−1,5,−3,7,−2}, your algorithm should return 1 and 3.b)Analyze the time complexity of your algorithm in the worst case.。
ASSIGNMENT 2 Solutions
E(x2 )
2 2 x f ( x)dx x 2 xdx 0
1
1 41 1 x 0 2 2
ASSIGNMENT 2
1. Three balls are drawn in succession without replacement from an urn containing 2 red balls and 3 black balls. Let W be a random variable giving the number of black balls minus the number of red balls drawn. List the elements of the sample space S for the three draws and to each sample point assign a value w of W. Key: S ●●● ●●● ●●● ●●● ●●● ●●● ●●● W -1 -1 -1 1 1 1 3
3. Consider the density function
2x ke , x 0 f ( x) 0, elsewhere
(a) Find the value of k (b) Find F(x) and use it to calculate P(-0.5<x<-0.2 ). Key:
3 0.1 0.133 0.167
0 X 1 2
(a) (b) (c) (d)
0 0.033 0.067
0.033 0.067 0.1
0.067 0.1 0.133
P( X P( X P( X P( X
1, Y 2) 0.067 0.1 0.167 ; 1, Y 1) 0.033 0.067 0.1 0.067 0.1 0.133 0.5 ; Y ) 0 0.033 0.067 0.1 0.067 0.1 0.133 0.133 0.167 0.8 ; Y 3) 0.1 0.1 0.1 0.3 ;
用电脑写作业英语三种
ing a Computer to Write Assignments in English:Tips and TricksWriting assignments in English on a computer can be a breeze if you follow these steps:Start with a Plan:Before you begin typing,outline your assignment.This helps in organizing your thoughts and ensures a smooth writing process.Use a Word Processor:Microsoft Word,Google Docs,or any other word processor is essential.They offer features like spell check,grammar check,and thesaurus which can be very helpful.Save Frequently:To avoid losing your work,make sure to save your document regularly.Autosave features can be a lifesaver.Utilize Formatting Tools:Make your assignment visually appealing by using headings, subheadings,bullet points,and numbered lists.Proofread:Use the proofreading tools provided by your word processor to catch any errors or inconsistencies.Cite Sources Properly:If your assignment requires referencing,use a citation manager like Zotero or Mendeley to keep track of your sources.Edit and Revise:After writing your first draft,take a break and then come back to revise your work.Look for areas that need improvement or clarification.Seek Feedback:If possible,have a peer or a teacher review your work for additional insights and suggestions.2.Writing Assignments in English on a Computer:A StepbyStep GuideHeres a stepbystep guide to writing assignments in English using a computer:Select the Right Software:Choose a word processor that you are comfortable with and that offers the features you need.Create a New Document:Start a new document and set the margins,font,and font size according to the assignment guidelines.Write an Introduction:Begin with a strong introduction that grabs the readers attentionand outlines the main points of your assignment.Develop Your Points:Use paragraphs to develop each point you want to make.Ensure each paragraph has a clear topic sentence.Incorporate Evidence:Support your arguments with evidence from your e intext citations to give credit to your sources.Write a Conclusion:Summarize your main points and restate your thesis in the conclusion.Use the Spell Checker:Run the spell check to find and correct any spelling errors.Check Grammar:Use the grammar check feature to identify and fix grammatical mistakes.Format the References:Ensure your references are formatted according to the required citation style.Print a Draft:Sometimes,reading a hard copy can help you catch errors that you might have missed on the screen.Revise Based on Feedback:Incorporate any feedback you receive to improve your assignment.3.Strategies for Writing English Assignments on a ComputerHere are some strategies to make your computerassisted writing process more efficient: Set Up a Comfortable Workspace:Ensure your workspace is comfortable and free from distractions.Use Keyboard Shortcuts:Learn and use keyboard shortcuts to save time on formatting and editing.Organize Your Research:Keep your research materials organized in folders or using notetaking apps.Break Down the Task:Divide your assignment into smaller tasks and tackle them one at a time.Use VoicetoText Software:If you find it faster to speak your ideas,use voicetotext software to transcribe your thoughts.Stay Focused:Use apps or tools that block distracting websites to help you stay focused on your writing.Experiment with Different Writing Times:Find out if you write better in the morning, afternoon,or evening,and schedule your writing sessions accordingly.Take Regular Breaks:Short breaks can help refresh your mind and improve your writing.Backup Your Work:Always keep a backup of your work on a cloud service or an external hard drive.Reflect on Your Progress:After completing an assignment,reflect on what worked well and what you can improve for next time.。
mt4中文帮助命令中文手册
MQL4 Reference MQL4命令手册(本手册采用Office2007编写)2010年2月目录MQL4 Reference (1)MQL4命令手册 (1)Basics基础 (12)Syntax语法 (12)Comments注释 (12)Identifiers标识符 (12)Reserved words保留字 (13)Data types数据类型 (13)Type casting类型转换 (14)Integer constants整数常量 (14)Literal constants字面常量 (14)Boolean constants布尔常量 (15)Floating-point number constants (double)浮点数常量(双精度) (15)String constants字符串常量 (15)Color constants颜色常数 (16)Datetime constants日期时间常数 (16)Operations & Expressions操作表达式 (17)Expressions表达式 (17)Arithmetical operations算术运算 (17)Assignment operation赋值操作 (17)Operations of relation操作关系 (18)Boolean operations布尔运算 (18)Bitwise operations位运算 (19)Other operations其他运算 (19)Precedence rules优先规则 (20)Operators操作符 (21)Compound operator复合操作符 (21)Expression operator表达式操作符 (21)Break operator终止操作符 (21)Continue operator继续操作符 (22)Return operator返回操作符 (22)Conditional operator if-else条件操作符 (23)Switch operator跳转操作符 (23)Cycle operator while循环操作符while (24)Cycle operator for循环操作符for (24)Functions函数 (25)Function call函数调用 (26)Special functions特殊函数 (27)Variables变量 (27)Local variables局部变量 (28)Formal parameters形式变量 (28)Static variables静态变量 (29)Global variables全局变量 (29)Defining extern variables外部定义变量 (30)Initialization of variables初始化变量 (30)External functions definition外部函数的定义 (30)Preprocessor预处理 (31)Constant declaration常量声明 (31)Controlling compilation编译控制 (32)Including of files包含文件 (32)Importing of functions导入功能 (33)Standard constants标准常数 (35)Series arrays系列数组 (35)Timeframes图表周期时间 (35)Trade operations交易操作 (36)Price constants价格常数 (36)MarketInfo市场信息识别符 (36)Drawing styles画线风格 (37)Arrow codes预定义箭头 (38)Wingdings宋体 (39)Web colors颜色常数 (39)Indicator lines指标线 (40)Ichimoku Kinko Hyo (41)Moving Average methods移动平均方法 (41)MessageBox信息箱 (41)Object types对象类型 (43)Object properties对象属性 (44)Object visibility (45)Uninitialize reason codes撤销初始化原因代码 (45)Special constants特别常数 (46)Error codes错误代码 (46)Predefined variables预定义变量 (50)Ask最新卖价 (50)Bars柱数 (50)Bid最新买价 (50)Close[]收盘价 (51)Digits汇率小数位 (51)High[]最高价 (51)Low[]最低价 (52)Open[]开盘价 (53)Point点值 (53)Time[]开盘时间 (53)Volume[]成交量 (54)Program Run程序运行 (56)Program Run程序运行 (56)Imported functions call输入函数调用 (57)Runtime errors运行错误 (57)Account information账户信息 (68)AccountBalance( )账户余额 (68)AccountCredit( )账户信用点数 (68)AccountCompany( )账户公司名 (68)AccountCurrency( )基本货币 (68)AccountEquity( )账户资产净值 (68)AccountFreeMargin( )账户免费保证金 (69)AccountFreeMarginCheck()账户当前价格自由保证金 (69)AccountFreeMarginMode( )账户免费保证金模式 (69)AccountLeverage( )账户杠杆 (69)AccountMargin( )账户保证金 (69)AccountName( )账户名称 (70)AccountNumber( )账户数字 (70)AccountProfit( )账户利润 (70)AccountServer( )账户连接服务器 (70)AccountStopoutLevel( )账户停止水平值 (70)AccountStopoutMode( )账户停止返回模式 (71)Array functions数组函数 (72)ArrayBsearch()数组搜索 (72)ArrayCopy()数组复制 (72)ArrayCopyRates()数组复制走势 (73)ArrayCopySeries()数组复制系列走势 (74)ArrayDimension()返回数组维数 (75)ArrayGetAsSeries()返回数组序列 (75)ArrayInitialize()数组初始化 (75)ArrayIsSeries()判断数组连续 (75)ArrayMaximum()数组最大值定位 (76)ArrayMinimum()数组最小值定位 (76)ArrayRange()返回数组指定维数数量 (76)ArrayResize()改变数组维数 (77)ArraySetAsSeries()设定系列数组 (77)ArraySize()返回数组项目数 (78)ArraySort()数组排序 (78)Checkup检查 (79)GetLastError( )返回最后错误 (79)IsConnected( )返回联机状态 (79)IsDemo( )返回模拟账户 (79)IsDllsAllowed( )返回dll允许调用 (80)IsExpertEnabled( )返回智能交易开启状态 (80)IsLibrariesAllowed( )返回数据库函数调用 (80)IsOptimization( )返回策略测试中优化模式 (81)IsStopped( )返回终止业务 (81)IsTesting( )返回测试模式状态 (81)IsTradeAllowed( )返回允许智能交易 (81)IsTradeContextBusy( )返回其他智能交易忙 (82)IsVisualMode( )返回智能交易“图片模式” (82)UninitializeReason( )返回智能交易初始化原因 (82)Client terminal客户端信息 (83)TerminalCompany( )返回客户端所属公司 (83)TerminalName( )返回客户端名称 (83)TerminalPath( )返回客户端文件路径 (83)Common functions常规命令函数 (84)Alert弹出警告窗口 (84)Comment显示信息在走势图左上角 (84)GetTickCount获取时间标记 (84)MarketInfo在市场观察窗口返回不同数据保证金列表 (85)MessageBox创建信息窗口 (85)PlaySound播放声音 (86)Print窗口中显示文本 (86)SendFTP设置FTP (86)SendMail设置Email (87)Sleep指定的时间间隔内暂停交易业务 (87)Conversion functions格式转换函数 (88)CharToStr字符转换成字符串 (88)DoubleToStr双精度浮点转换成字符串 (88)NormalizeDouble给出环绕浮点值的精确度 (88)StrToDouble字符串型转换成双精度浮点型 (89)StrToInteger字符串型转换成整型 (89)StrToTime字符串型转换成时间型 (89)TimeToStr时间类型转换为"yyyy.mm.dd hh:mi"格式 (89)Custom indicators自定义指标 (91)IndicatorBuffers (91)IndicatorCounted (92)IndicatorDigits (92)IndicatorShortName (93)SetIndexArrow (94)SetIndexBuffer (94)SetIndexDrawBegin (95)SetIndexEmptyValue (95)SetIndexLabel (96)SetIndexShift (97)SetIndexStyle (98)SetLevelStyle (98)SetLevelValue (99)Date & Time functions日期时间函数 (100)Day (100)DayOfWeek (100)Hour (100)Minute (101)Month (101)Seconds (101)TimeCurrent (101)TimeDay (102)TimeDayOfWeek (102)TimeDayOfYear (102)TimeHour (102)TimeLocal (102)TimeMinute (103)TimeMonth (103)TimeSeconds (103)TimeYear (103)Year (104)File functions文件函数 (105)FileClose关闭文件 (105)FileDelete删除文件 (105)FileFlush将缓存中的数据刷新到磁盘上去 (106)FileIsEnding文件结尾 (106)FileIsLineEnding (107)FileOpen打开文件 (107)FileOpenHistory历史目录中打开文件 (108)FileReadArray将二进制文件读取到数组中 (108)FileReadDouble从文件中读取浮点型数据 (109)FileReadInteger从当前二进制文件读取整形型数据 (109)FileReadNumber (109)FileReadString从当前文件位置读取字串符 (110)FileSeek文件指针移动 (110)FileSize文件大小 (111)FileTell文件指针的当前位置 (111)FileWrite写入文件 (112)FileWriteArray一个二进制文件写入数组 (112)FileWriteDouble一个二进制文件以浮动小数点写入双重值 (113)FileWriteInteger一个二进制文件写入整数值 (113)FileWriteString当前文件位置函数写入一个二进制文件字串符 (114)Global variables全局变量 (115)GlobalVariableCheck (115)GlobalVariableDel (115)GlobalVariableGet (115)GlobalVariableName (116)GlobalVariableSet (116)GlobalVariableSetOnCondition (116)GlobalVariablesTotal (117)Math & Trig数学和三角函数 (119)MathAbs (119)MathArccos (119)MathArcsin (119)MathArctan (120)MathCeil (120)MathCos (120)MathExp (121)MathFloor (121)MathLog (122)MathMax (122)MathMin (122)MathMod (122)MathPow (123)MathRand (123)MathRound (123)MathSin (124)MathSqrt (124)MathSrand (124)MathTan (125)Object functions目标函数 (126)ObjectCreate建立目标 (126)ObjectDelete删除目标 (127)ObjectDescription目标描述 (127)ObjectFind查找目标 (127)ObjectGet目标属性 (128)ObjectGetFiboDescription斐波纳契描述 (128)ObjectGetShiftByValue (128)ObjectGetValueByShift (129)ObjectMove移动目标 (129)ObjectName目标名 (129)ObjectsDeleteAll删除所有目标 (130)ObjectSet改变目标属性 (130)ObjectSetFiboDescription改变目标斐波纳契指标 (131)ObjectSetText改变目标说明 (131)ObjectsTotal返回目标总量 (131)ObjectType返回目标类型 (132)String functions字符串函数 (133)StringConcatenate字符串连接 (133)StringFind字符串搜索 (133)StringGetChar字符串指定位置代码 (133)StringLen字符串长度 (134)StringSubstr提取子字符串 (134)StringTrimLeft (135)StringTrimRight (135)Technical indicators技术指标 (136)iAC比尔.威廉斯的加速器或减速箱振荡器 (136)iAD离散指标 (136)iAlligator比尔・威廉斯的鳄鱼指标 (136)iADX移动定向索引 (137)iATR平均真实范围 (137)iAO比尔.威廉斯的振荡器 (138)iBearsPower熊功率指标 (138)iBands保力加通道技术指标 (138)iBandsOnArray保力加通道指标 (139)iBullsPower牛市指标 (139)iCCI商品通道索引指标 (139)iCCIOnArray商品通道索引指标 (140)iCustom指定的客户指标 (140)iDeMarker (140)iEnvelopes包络指标 (141)iEnvelopesOnArray包络指标 (141)iForce强力索引指标 (142)iFractals分形索引指标 (142)iGator随机震荡指标 (142)iIchimoku (143)iBWMFI比尔.威廉斯市场斐波纳契指标 (143)iMomentum动量索引指标 (143)iMomentumOnArray (144)iMFI资金流量索引指标 (144)iMA移动平均指标 (144)iMAOnArray (145)iOsMA移动振动平均震荡器指标 (145)iMACD移动平均数汇总/分离指标 (146)iOBV能量潮指标 (146)iSAR抛物线状止损和反转指标 (146)iRSI相对强弱索引指标 (147)iRSIOnArray (147)iRVI相对活力索引指标 (147)iStdDev标准偏差指标 (148)iStdDevOnArray (148)iStochastic随机震荡指标 (148)iWPR威廉指标 (149)Timeseries access时间序列图表数据 (150)iBars柱的数量 (150)iClose (150)iHigh (151)iHighest (151)iLow (152)iLowest (152)iOpen (152)iTime (153)iVolume (153)Trading functions交易函数 (155)Execution errors (155)OrderClose (157)OrderCloseBy (158)OrderClosePrice (158)OrderCloseTime (158)OrderComment (159)OrderCommission (159)OrderDelete (159)OrderExpiration (160)OrderLots (160)OrderMagicNumber (160)OrderModify (160)OrderOpenPrice (161)OrderOpenTime (161)OrderPrint (162)OrderProfit (162)OrderSelect (162)OrderSend (163)OrdersHistoryTotal (164)OrderStopLoss (164)OrdersTotal (164)OrderSwap (165)OrderSymbol (165)OrderTakeProfit (165)OrderTicket (166)OrderType (166)Window functions窗口函数 (167)HideTestIndicators隐藏指标 (167)Period使用周期 (167)RefreshRates刷新预定义变量和系列数组的数据 (167)Symbol当前货币对 (168)WindowBarsPerChart可见柱总数 (168)WindowExpertName智能交易系统名称 (169)WindowFind返回名称 (169)WindowFirstVisibleBar第一个可见柱 (169)WindowHandle (169)WindowIsVisible图表在子窗口中可见 (170)WindowOnDropped (170)WindowPriceMax (170)WindowPriceMin (171)WindowPriceOnDropped (171)WindowRedraw (172)WindowScreenShot (172)WindowTimeOnDropped (173)WindowsTotal指标窗口数 (173)WindowXOnDropped (173)WindowYOnDropped (174)Obsolete functions过时的函数 (175)MetaQuotes Language 4 (MQL4) 是一种新的内置型程序用来编写交易策略。
Assignment 1_Solution
5. (5-24) A stock is expected to pay a dividend of $1 per share in two months and in five months. The stock price is $50, and the risk-free rate of interest is 8% per annum with continuous compounding for all maturities. An investor has just taken a short position in a six-month forward contract on the stock. a) What are the forward price and the initial value of the forward contract? b) Three months later, the price of the stock is $48 and the risk-free rate of interest is still 8% per annum. What are the forward price and the value of the short position in the forward contract? Solution: a) The present value, I, of the income from the security is given by: I = 1× e −0.08×2/12 + 1× e −0.08×5/12 = 1.9540. From equation (2.3) the forward price, F0, is given by: F0 = (50 − 1.9540)e0.08×6/12 = 50.01. The initial value of the forward contract is (by design) zero. The fact that the forward price is very close to the spot price should come as no surprise. When the compounding frequency is ignored the dividend yield on the stock equals the riskfree rate of interest. b) In three months: I= 1× e −0.08×2/12 = 0.9868. The delivery price, K, is 50.01. From equation (2.9) the value of the short forward contract, f, is given by: f = −(48 − 0.9868 − 50.01e −0.08×3/12 ) = 2.01. And the forward price is (48 − 0.9868)e0.08×3/12 = 47.96. 6. (5-27) A trader owns gold as part of a long-term investment portfolio. The trader can buy gold for $550 per ounce and sell gold for $549 per ounce. The trader can borrow funds at 6% per year and invest funds at 5.5% per year. (Both interest rates are expressed with simple annual compounding.) For what range of one-year forward prices of gold does the trader have on arbitrage opportunities? Assume there is no bid-offer spread for forward prices.
Assignment_1_suggested_solutions
Speaking of Statistics(12) - Assignment 1 – Suggested Solution1. Below we list several variables. Which of these variables are quantitative and which arequalitative? Explain.a. The dollar amount on an accounts receivable invoice. → Quantitativeb. The net profit for a company in 2005. → Quantitativec. The stock exchange on which a company’s stock is traded. → Qualitative d. The national debt of the United States in 2005. → Quantitativee. The advertising medium (radio, television, or print) used to promote a product. → Qualitative2. Classify each of the following qualitative variables as ordinal or nominative. Explain youranswers.Qualitative Variables The Corresponding CategoriesStatistics course letter grade A B C D F →Ordinal Personal computer ownership Yes No → Nominal Restaurant rating ***** **** *** ** * → Ordinal Incoming tax filing status Married filing jointly; Married filing separately; Single; Headof household; Qualifying widow(er) → Nominal3. Forbes magazine publishes the Forbes Platinum 400 –a list of the ―Best Big Companies inAmerica‖ as selected by the magazine’s writers and editors. Table above gives the best companies in the retailing industry as given in this list on the Forbes website on March 16, 2005. (Data in the last page ).b. Organize data of the profit margin percentages into a frequency distribution.Number of class K=6 (Since n K≥2 where n is the total number of data = 35.) The class length is calculated as 9.381.361.10.24≈=-=K rangea. Construct a stem-and leaf display of the return on capital percentages for the retailers in Table.Find the median and then describe the distribution of the return.The median is the 18th measurement, 15.4.The data are widely spread out, with majority falling in the range [8.3, 22.8]. The distribution is somewhat symmetric, with extreme values at both ends.c.Construct a histogram of the profit margin percentages.4. In order to control costs, a company wishes to study the amount of money its sales forcespends entertaining clients. The following is a random sample of six entertaining expenses (dinner costs for four people) from expense reports submitted by members of the sales force $157 $132 $109 $145 $125 $139a. Show the equivalence of the following two formulas:,.Solutions:()⎥⎦⎤⎢⎣⎡--=⎥⎥⎦⎤⎢⎢⎣⎡⎪⎪⎭⎫ ⎝⎛+--=++++++-+++-=+-+++-++--=-++-+--=--=--=∑∑∑∑∑∑∑∑22222221222212222222121222212221 1 1)(2(11)]...()2...22()...[(11)]2(...)2()2[(11])(...)()[(11)(111)(i i i i i i n n n n n i ix n x n n x n x n x x n x x x x x x x x x x x n x x x x x x x x x x x x n x x x x x x n x x n n x x sb. Calculate x , 2s , and s for the expense data, use the two different formulas in (a) to calculate 2s .Solutions 5.1346139125145109132157=+++++=x7.27616)5.134 139()5.134 132()5.134 157(2222=+++= s , 63.167.276==sOr using another formula:925,1091391251451091321572222222=+++++=∑ix()249,651)807()139125145109132157(222==+++++=∑ix()⎥⎦⎤⎢⎣⎡--=∑∑2221 1 1i i x n x n s 7.276)249,651(61–925,1091–61=⎥⎦⎤⎢⎣⎡=5. On February 15, 2005, the Gallup Organization released the results of a Gallup UK poll regarding Internet usage in Great Britain. Each of 1,009 randomly selected UK adults was asked to respond to the following question:How much time, if at all, do you personally spend using the Internet-more than an hour a day, up to one hour a day, a few times a week, a few times a month or less, or never?The poll’s results were as follows: More than an hour a day (22%); Up to an hour a day (14%);A few times a week (15%); A few times a month or less (10%); Never (39%). Use these datato construct a bar chart and a pie chart.Bar Chart:Pie Chart:6. Thirteen internists in the Midwest are randomly selected, and each internist is asked to report last year’s income. The incomes obtained (in thousands of dollars) are127 132 138 141 144 146 152 154 162 171 177 192 241 Find:There are 13 measurements in total (n=13). They are already in ascending order. a. The 90th percentile.Calculate the index of the 90thpercentile: 7.111310090=⨯=i Round 11.7 up to 12, hence the 90th percentile is the 90th measurement 192.b. The median.The median is equivalent to the 50thpercentile: 5.61310050=⨯=i Round 6.5 up to 7, hence the median is the 7th measurement 152.c. The first quartile.We know the index of the first quartile can be found as: 25.31310025=⨯=i Round 3.25 up to 4, hence the first quartile is the 4th measurement 141.d. The third quartileWe know the index of the third quartile can be found as: 75.91310075=⨯=i Round 9.75 up to 10, hence the third quartile is the 10th measurement 171.e. The 10th percentile.Calculate the index of the 10thpercentile: 3.11310010=⨯=i Round 1.3 up to 2, hence the 10th percentile is the 2nd measurement 132.f. The interquartile range.Interquartile range is the difference between first and third quartile3014117113=-=-=Q Q IQRg. Develop a five-number summary and a box-and-whiskers display.7. According to the website, the 2004 total return percentages for several popular funds were as follow:Fund 2004 Total Return% Vanguard 500 Index 10.7Wasatch Core Growth 21.7 Fidelity Stock Selector 9.9 Fidelity Dividend Growth6.0Janus Worldwide 5.2Suppose that an investor had $100,000 invested in the Vanguard 500 Index fund, $500,000 invested in the Wasatch Core Growth fund, $500,000 invested in the Fidelity Stock Selector fund, $200,000 invested in the Fidelity Dividend Growth fund, and $50,000 invested in the Janus Worldwide fund.a. Compute a weighted mean that measures the 2004 average total return for the investor ’s portfolio.Compare your weighted mean with the un-weighted mean of the five total return percentages. Explain why they differ.The weighted mean is%56.13000,350,1000,305,18000,50000,200000,500000,500000,100)5.5(000,50)8.5(000,200)9.9(000,500)7.21(000,500)7.10(000,100==++++++++=μAnd the un-weighted mean is%72.1055.58.59.97.217.10=++++The average total return calculated using weighted mean is higher because more money was invested in funds with larger gains, such as Wasatch Core Growth.8. As given on the Morningstar website, the mean return for Fidelity Leveraged Company Stock is 17.98 percent with a standard deviation of 10.02 percent, while the mean return for Baron Opportunity Retail Stock is 16.43 percent with a standard deviation of 12.23 percent. Which stock do you buy? (Which is riskier than the other one?)The mean return for Fidelity Leveraged Company Stock is higher than of Baron Opportunity Retail Stock.When we compute and compare the coefficient of variation for these two stocks using 100mean deviationstandard ⨯ , we find that the coefficient of variation of Fidelity Leverage(73.5510017.9810.02=⨯) is lower than the one of Baron Opportunity (44.7410016.4312.23=⨯), meaning the variation in returns for the Baron Opportunity is higher, so investing in Baron Opportunity is riskier.Therefore investing in Fidelity Leveraged Company Stock is more advisable.9. The card game of Euchre employs a deck that consists of all four of each of the aces, kings, queens, jacks, tens, and nines (one of each suit —clubs, diamonds, spades, and hearts). Find the probability that a randomly selected card from a Euchre deck isThere are a total of 24 cards (4 aces, 4 kings, 4 queens, 4 jacks, 4 tens and 4 nines.a. A jack (J)The probability of selecting a jack is ()61244==J P b. A spade (S)The probability of selecting a spade card is 41246)(==S P c. A jack or an ace (A)The probability of selecting a jack OR an ace is()()()()3106161=-+=⋂-+=⋃A J P A P J P A J P d. A jack or a spade.The probability of selecting a jack OR a spade card is()()()()832414161=-+=⋂-+=⋃S J P S P J P S J P e. Are the events J and A mutually exclusive? J and S? Why or Why not?The events J and A are mutually exclusive because one cannot draw a Jack AND an Ace at the same time in one single draw.The events J and S are NOT mutually exclusive because one can draw a jack of spade under one single draw, hence J and S could occur simultaneously.10. Fifteen percent of the employees in a company have managerial positions, and 25 percent of the employees in the company have MBA degrees. Also, 60 percent of the managers have MBA degree.a. What proportion of employees are managers and have MBA degrees. 9% of employees are managers AND have MBA degrees09.0)6.0)(15.0()|()()(===⋂Manager MBA P Manager P MBA Manager Pb. What proportion of MBAs are managers. 36% of MBAs are managers36.025.009.0)()()|(==⋂=MBA P MBA Manager P MBA Manager Pc. Are the events being a manager and having an MBA independent? Justify your answer.No. Because 15.0)(36.0)|(=≠=ManagerP MBA Manager P11. In a survey of 100 insurance claims, 40 are fire claims (FIRE ), 16 of which are fraudulent (FRAUD ). Also, there are a total of 40 fraudulent claims. a. Construct a contingency table summarizing the claims data. Use the pairs of events FIRE and FIRE , FRAUD and FRAUD .Contingency Table:FireFIRETotal Fraud 16 24 40 Fraud 24 36 60Total4060100b. What proportion of the fire claims are fraudulent? 40% of the fire claims are fraudulent4.04016)()()|(==⋂=Fire P Fire Fraud P Fire Fraud Pc. Are the events a claim is fraudulent and a claim is a fire claim independent? Use your probability of part b to prove your answer. Yes. Because10040)(4.0)|(===Fraud P Fire Fraud P12. Each month a brokerage house studies various companies and rates each company’s stock as being either ―low risk‖ or ―moderate to high risk.‖ In a recent report, the brokerage house summarized its findings about 15a.The probability that the company’s stock is moderate to high risk giventhat the firm is an aerospace company.P(ModToHigh | Areo) = 9/15=0.6b.T he probability that the company’s stock is moderate to high risk giventhat the firm is a food retailer.P(ModToHigh | Food) = 10/25=0.4c.Determine if the company type is independent of the level of risk of thefirm’s stock.If the company type is independent of the level of risk of the firm’s stock, the we should find equalities such asP(Aero | Low) = P(Aero)However, P(Aero | Low) = 2/7 while P(Aero) = 3/8.The two probabilities are not equal. Hence the two events are dependent.Table for question 3:The Forbes platinum list: Best-performing retailers as listed at on March 16, 2005。
数字信号处理(英文版)课后习题答案2
(Partial) Solutions to Assignment 2pp.73-761.16In each of the following systems, let or be the input and or be the output. Determine whether each systems is (1) linear, (2) time invariant, (3) causal, (4) BIBO stable(g).(i).ans: omitted----------------------------------------------------1.17 A linear time invariant system has impulse response Determine the output sequence for each of the followign input signals:(b)(f)(b) ans:h n is given byThe z-transform of []where ROC1:x n is given byz-transform of []where ROC2:h n is given byTherefore, the z-transform of the output []y nPerform inverse z to get [](f) ans: using the same method as in (b) (details omitted )----------------------------------------------------1.18. A linear time invariant system is defined by the difference equationb. Determine the output of the system when the intpu isc. Determine the output of the system when the input isans: omitted----------------------------------------------------1.19 The following expressions define linear time invariant systems. For each one determine the impulse respnose(a)(e)(a) ans: the impulse response is(e) ans: the impulse response is----------------------------------------------------1.20 Each of the following expressions defines a linear time invariant system. For each one determine whether it is BIBO stable or not(g)(k)BIBO: Bounded input and bounded output(g) ans: omitted(k) ans: omitted----------------------------------------------------1.21. Using the geometric series, for each of the following sequence determine the z-transform and its ROC(d)(g)(i)(d) ans:where ROC:(g) ans:The first part is equal towhere ROC1 isThe second part is equal towhere ROC2 isTherefore combining both parts:where ROC={ROC1 and ROC2}:(i) ans:where ROC: whole complex domain----------------------------------------------------1.22. You know what the and are. Using theproperties only (do not reuse the definition of the z-transform.) determine the z-transform of the following signals(c)(g)where ROC1:where ROC2:(c) ans: using z-transform property:We have:where ROC:(g) ans:details omitted. The final answer isTherefore combining both parts:where ROC={ROC1 and ROC2}:----------------------------------------------------1.23 Using partial fraction expansion, determine the inverse z-transform of the following functions:(c) ,(e) ,(c) ans:(e) ans:procedures are the same as above. details omitted.----------------------------------------------------1.24. For each of the followign linear difference equations, determine the impulse response, and indicate whether the system is BIBO stable or not(a)(c)(a) ans:Take z-transform on both sideswhere ROC:Because is finiteTherefore, the system is BIBO stable(c) ans: omitted (the same as (a))----------------------------------------------------1.25. Although most of the time we assume causality, a linear difference equation can be interpreted in a number of ways. Consider the linear difference equation(a) Determine the transfer function and the impulse response. Is the system causal ? BIBO stable ?(a) omitted.----------------------------------------------------1.26. 1.26 Consider the linear difference equation(a) Determine the transfer function . Do you have enough information to determine theregion of convergenceans:Don't have enough information to determine ROC.----------------------------------------------------1.27. Given the system described by the linear difference equationDetermine the output for each of the following input signals(a)(e)(a) ans:Take z-transform on both sides:----------------------------------------------------1.28. Repeat Problem 1.27 when the system is given in terms of the impulse responseBefore you do anything, is the system stable ? Does the frequency responseexist ?ans: omitted.----------------------------------------------------1.29. Repeat Problem 1.27 when the system isgiven by the linear difference equationBefore you do anything, is the system stable ? Does the frequency response exist ?Ans: omitted.----------------------------------------------------。
现代机器人作业答案
Q-1. A vector AP is rotated about ������! by 30 degrees and is subsequently rotated about ������! by 45 degrees. Give the rotation matrix that accomplishes these rotations in the given order.
" $
c1c23
−c1s23
s1
c1(c2l2 + l1)
% '
03T
$ =$
$
s1c23 s23
−s1s23 c23
−c1 0
s1(c2l2 + l1)
' '.
s2l2
'
$ #
0
00
1
' &
Solution: Case (1):
Case (2):
Q-9. (a) Describe a simple algorithm for choosing the nearest solution from a set of possible solutions.
Solution:
Figure Q-7
Q-8. For the cases of (1) both the desired orientation and position of the tip frame with respect to the base frame are given as:
assignment1-solution
Operations ResearchLecture 0: Assignment 1Notes taken by Kaiquan XuDue Date: October 18th 20121Assignment DescriptionGiven a manufacturer plans to produce two types of products: I and II, the required matireials (A & B) and equipment for producting one product are list in Table 1. The profits for Product I and II are 2$ and 3$.The question is: how to make product planning, so the manufacturer can get the maximum profit.1)Please write this problem as a linear programming problem (10 marks).2)Try to draw the graphical representation and find its solution (10 marks).3)Try to use the simplex method to find its optmial solution (30 marks).4)Try to write its dual problem (15 marks).5)2Solution1)Please write this problem as a linear programming problem (10 marks)Let x1and x2be as the numbers of Product I and II to be produced. Under the constraints of the resources, the variables should satisfy the following conditions:x1 + 2x2≤84x1≤164x2≤12The profit z can be represented as z = 2x1 + 3x2. This problem can be described as the following math model:max z = 2x1 + 3x2s.t. x1 + 2x2≤ 84x1≤ 164x2≤ 12x1, x2≥ 012B − − u i u 2) Try to drop the graphical representation and find its solution (10 m arks) (skip)3) Try to use the simplex method to find its optmial solution (30 marks)Transform this problem into the standard formmin 2x 1 3x 2s.t. x 1 + 2x 2 + x 3 = 8x 1 + x 4 = 4 x 2 + x 5 = 3x 1, x 2, x 3, x 4, x 5 ≥ 0It is obvious that x = (0, 0, 8, 4, 3)T is a basic feasible solution. That is x 3, x 4, x 5 are as the basic variables, then the 1 0 0corresponding basis matrix B = 0 1 0 , c B = 0, therefore c T B = 0 and c = c .0 0 1x 1 x 2 x 3 x 4 x 5 0-2 -3 0 0 0 x 3 = 8 1 2 1 0 0 x 4 = 4 1s 0 0 1 0 x 5 = 31 0 0 1The reduced cost of x 1 is negative and we let that variable enter the basis. The pivot column u = (1, 1, 0)T , andcaculate the ratios x B (i ), i = 1, 2, the smallest ratio corresponds to i = 2. We select x 4 to exist the basis. Then x 3, x 1, x 5 are the new basic variables. Then we do some row operations to get the new tableaux 1 x 2 x 3 x 4 x 5 80 -3 0 2 0 x 3 = 4 0 2∗ 0 -1 0 x 1 = 4 1 0 0 1 0 x 5 = 31 0 0 1The corresponding basic feasible solution is x = (4, 0, 4, 0, 3)T . x 2 has negative reduced cost, we choose x 2 to theone that enter the basis. The pivot column is u = (2, 0, 1)T . We only caculate the ratioes x B (i ), for i = 1, 3. We select i x 3 exist the basis, then execute the row operations.x 1 x 2 x 3 x 4 x 5 14 0 0 0 1/2 0 x 2 = 2 0 1 0 -1/2 0 x 1 = 4 1 0 0 1 0 x 5 = 10 0 1/2 1Now, all reduced costs are nonnegative. We get the optimal solution 4) Try to write its dual problem (15 marks)The dual of this problem ismax 8p1 + 4p2 + 3p3s.t. p1 + p2≤ −22p1 + p3≤−3p1≤0p2≤0p3≤05)Since x∗1 >0and x∗2 >0,we havep1 + p2 = −22p1 + p3 = −3By solving this equations, we get p1 = −3/2, p2 = −1/2, p3 = 0, which is a dual optimal solution. Here, the simplex method for the dual problem is skipped.3。
ecm06-hw1-solutions
Winter 06
Econometrics
ASSIGNMENT 1 - SOLUTIONS
100 POINTS TOTAL
DUE: Thursday, January 26, 3:20 p.m.
1. [5] Let X be the random variable distributed as Normal (5,4). Find the probabilities of the following events: (i) P(X ≤ 6) (ii) P(X > 4) (iii) P(|X – 5| > 1) (i) P(X ≤ 6) = P[(X – 5)/2 ≤ (6 – 5)/2] = P(Z ≤ .5) [We obtain P(Z ≤ .5) from Table 1.]
assignment1
CSC415/CI6226 2011 P rogramming A ssignment 1 (100 p oints) Objectives: I n t his a ssignment, y ou w ill•Build a s pelling c orrection e ngine•Build a t ext s earch e ngine w ith L ucene, a nd•Integrate y our s pelling c orrector i nto t he t ext s earch e ngineDue: M arch 10, 2011 (Thursday) 11:59pm. L ate s ubmissions a re a llowed b ut w ill b e p enalized a t a r ate of 10% p er d ay.Teams: Y ou a re a llowed (but n ot r equired) t o w ork i n p airs f or t his a ssignment. T eams o f t wo s hould only s ubmit o ne c opy o f t heir w ork. Y ou m ay (and a re e ncouraged t o) d iscuss w ith o ther t eams, b ut should N OT t ake a ny d etailed n otes f rom t he d iscussions t hat w ill a ppear v erbatim i n y our s ource c odes and r eports.Implementation: W e s trongly r ecommend t hat y ou w rite y our p rogram i n J ava, t hough y ou m ay u se other p rogramming l anguages (e.g. C, C++, P ython) w ithout o fficial s upport (e.g. L ucene). Delivery: Y ou s hould s ubmit t he f ollowings v ia e mail t o j ungjae.kim@.sg:•A z ip f ile t hat c ontains t he c odes y ou w rote (Do N OT i nclude d ata f iles a nd c ompiled l ibraries) •A t ext f ile w ith p rogram o utput•A d ocument i n r eadable E nglish s entences w ith f igures o r t ables a s n eeded. T he d ocument should N OT h ave m ore t han 4 p ages (excluding f igures a nd t ables). I t s hould c ontain o The n ames o f t eam m emberso Descriptions o f w hat y ou h ave d one f or e ach p art, r epresentative o utput f rom y our program, a ny n otable d esign d ecisions m ade o r t rade-‐offs c onsidered (withjustifications), a nd a n e rror a nalysis o f w hen y our s ystem f ailso Detailed i nstructions o n h ow t o c ompile a nd r un t he c odes f or e ach p art, i ncluding where t o p lace d ata f iles a nd l ibraries u sed. I f y ou u se a ny o ther r esource f iles e xceptthose p rovided b y u s, p lease p lace t hem i n a W eb s ite (e.g. N TU M ySite) a nd d escribehow t o d ownload t hem s o t hat w e c an d ownload a nd t est t hem. P lease m ake s ure t heinstructions w ork o n o ther m achines e xcept y ours b efore s ubmission. Y ou w ill l osepoints i f y our c odes f ail t o c ompile o r r un o n t he e valuator’s m achine.If y our e mail s ubmission i s r eturned b ack t o y ou a s a s pam d ue t o t he c odes b y t he N TU e mail s ystem, you s hould s ubmit t he p rogram o utput a nd t he d ocument b y e mail b y t he d eadline a forementioned a nd bring a U SB m emory d evice w ith t he c odes t o t he o ffice (N4-‐02c-‐111) d uring o ffice h ours o n M arch 11. Honor c ode: Y ou s hould n ot l ook f or p roblem a nswers e lsewhere. B ut, i f m aterial i s t aken f rom elsewhere, t hen y ou s hould a cknowledge i t. Y ou a re n ot p ermitted t o g et p rogramming h elp f rom people o ther t han y our p artner. I n g eneral, w e w ill e xpect y ou t o a ct o n y our h onor.Part 1: S pelling C orrection (40 p oints)In t his p art y ou w ill b uild a n n-‐gram b ased s pelling c orrector. I n l ecture 3 (tolerant r etrieval), w e s aw that o ne w ay t o o ffer s pelling s uggestions w as t o c ount t he p roportion o f c haracter n-‐grams t hat o verlap between t he q uery w ord a nd k nown w ords f rom a c orpus. D oing s o w ill r equire a n i nverted i ndex t hat maps n-‐grams t o d ictionary w ords a nd a s coring f unction t hat c ounts n-‐gram o verlaps b etween candidate w ords. Y ou a re o n y our o wn f or b uilding t he i nverted i ndex -‐ y ou s hould n ot u se a ny e xisting libraries o r c ode s nippets t o d o t his f or y ou. Y ou s hould i mplement t he J accard s core o f n-‐gram o verlap as d escribed i n c lass a s t he s coring f unction f or c andidate r eplacements.Take a l ook a t t he s .ntu.ir.spell.SpellingCorrector i nterface:package .ntu.ir.spell;import java.util.List;/*** Basic interface for the spelling corrector.** @author dramage (revised by kim)*/public interface SpellingCorrector {/*** Returns a list of top-scoring spelling corrections for a given* (possibly misspelled) word. The list is expected to include* the best corrected spelling. The maximum length of the* returned list will be specified, while the actual length of* the list may be smaller than it.** @param word A single word whose spelling is to be checked.* @param max The maximum number of corrections in the* returned list. Should be greater than 0.* @return A list of top-scoring corrections, with better corrections* ordered first.*/public List<String> corrections(String word, int max);}Your n-‐gram b ased s pelling c orrector w ill i mplement t his i nterface t o r eturn a l ist o f m ost l ikely candidate s pelling c orrections f or a g iven (possibly m isspelled) w ord.Your s pelling c orrector s hould r ead a ll t he w ords f rom a l arge f ile o f E nglish t ext. Y ou m ay u se t he t ext file (‘big.txt’) t hat c omes f rom P eter N orvig's p age o n H ow t o W rite a S pelling C orrector, w hich t akes a n alternative a pproach t o b uilding a s pell c hecker. [From N orvig's s ite: "The f ile i s a c oncatenation o f several p ublic d omain b ooks f rom P roject G utenberg a nd l ists o f m ost f requent w ords f rom W iktionary and t he B ritish N ational C orpus."]You m ust c omplete t he f ollowing s ub-‐problems:1.1. I mplement a n n-‐gram s pelling c orrector (named s .ntu.ir.spell.NGramSpellingCorrector) b asedon t he w ords i n t he f ile b ig.txt. B riefly d escribe y our i mplementation a nd p rovide s ome e xample mis-‐spelled w ords a long w ith t he p ossible c orrections y our a lgorithm p rovides. W hat i s t he o utput of s .ntu.ir.spell.SpellingScorer c lass (see b elow) w hen r un w ith a rguments s hown b elow (a-‐d)?What a re t he s ources o f e rrors?.ntu.ir.spell.NGramSpellingCorrector 1 ‘path t o s pelltest1.txt’.ntu.ir.spell.NGramSpellingCorrector 1 ‘path t o s pelltest2.txt’.ntu.ir.spell.NGramSpellingCorrector 10 ‘path t o s pelltest1.txt’.ntu.ir.spell.NGramSpellingCorrector 10 ‘path t o s pelltest2.txt’1.2. I n c lass, i t i s m entioned t hat a n n-‐gram b ased c orrector c ould b e u sed i n c oncert w ith a n e ditdistance f unction. W rite a n i mplementation o f L evenshtein e dit d istance a nd a n ew i mplementation of S pellingCorrector, c alled N GramWithEditDistanceSpellingCorrector, t hat w raps t he u nderlying spelling c orrector a nd r e-‐scores i ts o utput u sing t he w eighted e dit d istance f unction. I n p articular, use y our n-‐gram s pelling c orrector t o g et s ome n umber o f c losest c andidates i n t he d ictionary, score e ach w ith t he E dit d istance f unction a nd t hen s uggest t he c orrections w ith l owest e ditdistance. P rovide o utput, e xamples, a nd e rror a nalysis a s y ou d id f or s ub-‐problem 1.1, w hilereplacing ‘NGramSpellingCorrector' w ith ‘NGramWithEditDistanceSpellingCorrector' i n t hearguments.1.3. W rite a w eighted e dit d istance f unction a nd u se i t f or a n ew i mplementation o f S pellingCorrector,called N GramWithWeightedEditDistanceSpellingCorrector. Y ou s hould d efine y our o wn w eighting scheme, f or e xample, a llowing d ifferent w eights f or d ifferent k inds o f e dit o perations a nd d ifferent weights f or d ifferent c haracter r eplacements. H ow d id y ou f ind t he w eighting s cheme a nd w hy?What i s t he i mpact o f a ny c hanges o n t he s cheme? P rovide o utput, e xamples, a nd e rror a nalysis a s you d id f or s ub-‐problem 1.1, w hile r eplacing ‘NGramSpellingCorrector' w ith‘NGramWithWeightedEditDistanceSpellingCorrector' i n t he a rguments.Using S pellingScorer a nd A utomatic Q uantitative G radingThe i ncluded c lass s .ntu.ir.spell.SpellingScorer p rovides a w ay t o t est t he r esults o f y our SpellingCorrector i mplementations a cross a c ollection o f s pelling e rrors (see t he N orvig's s ite). T o r un the S pellingScorer, y ou s hould p rovide t he f ollowing t hree a rguments:1.Java c lass o f t he s pelling c orrector t o b e t ested2.The m aximum n umber o f c orrections f or e ach m is-‐spelling t o b e t ested.3.Path t o t he d ata f ile t o b e t ested (e.g. s pelltest1.txt, s pelltest2.txt).(You m ay r evise t he r eleased v ersion o f S pellingScorer f or y our p rogram i f n ecessary. F or e xample, i t does n ot a llow w hite s paces i n t he f ile p ath, a nd y ou c an r evise t o f ix t he p roblem.)For e xample, y ou m ay r un i t a s f ollows:$ j ava -‐cp b in/ s .ntu.ir.spell.SpellingScorer s .ntu.ir.spell.NGramSpellingCorrector 1data/spelltest1.txtThe S pellingScorer c hecks, f or e ach m is-‐spelling i n t he d ata f ile, i f t he l ist o f c orrections r eturned b y t he given S pellingCorrector i ncludes t he e xpected c orrected s pelling. S pellingScorer w ill r eport t he performance o f t he S pellingCorrector b ased o n t he d ata f ile.You m ust i nclude t he o utput o f t his p rogram i n y our s ubmission. W e a lso m ay u se t he S pellingScorer o n a d ifferent s et o f w ords t o e valuate t he q uality o f y our i mplementation.Part 2: L ucene (50 p oints)In t his p art y ou b uild u p a s earch e ngine f or t he c ollection o f 30,000+ T DT3 n ews a rticles (i.e. ‘tdt3.zip’) by u sing L ucene, a t ext s earch e ngine l ibrary w ritten i n J ava. T he c ollection c onsists o f t ext f iles, w here each f ile c ontains a n ews a rticle. A n e xample f ile i s s hown b elow.File: tdt3/19981001/CNN19981001_1600_1059.txt<DOC><DOCNO> CNN19981001.1600.1059 </DOCNO><DOCTYPE> NEWS </DOCTYPE><TXTTYPE> CAPTION </TXTTYPE><TEXT>General Motors is taking another step in its effort to lure customersback after strikes shut down most of its plants this summer. G.M.says it will install a safety and security system on many of its trucksand cars for free. The system is worth about $1,300. G.M. saw itsmarket share shrink from 31% in June to less than 21% in July as thestrike was taking place.</TEXT></DOC>Your t ask i s t o c reate a L ucene i ndex f or t he c ollection, w rite a p rogram t hat t akes i n a q uery f rom t he user (i.e. S ystem.in) a nd r eturns a l ist o f t op 20 d ocuments, a nd i ntegrate s pelling c orrectors w ith t he program. T he i ndex s hould h ave t he f ollowing t hree f ields: d ocno (called I Ds), d ate (inferrable f rom t he sub-‐directory n ames, e.g., 19981001), a nd t ext.2.1 I mplement s ome q ueries i n t he p rogram t o f ind t he I Ds (e.g. C NN19981001.1600.1059) o f t he documents t hat m eet t he f ollowing c onditions:a)Documents t hat c ontain b oth “New Y ork” a nd “San F rancisco”b)Documents w here t he w ords ‘helicopter’ a nd ‘hurricane’ a ppear w ithin 5 w ords o f e ach o therc)Documents w hich c ontain t he n ame “Dan R onan” a nd w as p ublished i n N ovember 19982.2 A ssume t hat w e a re i nterested i n n ews a rticles a bout s tock m arket m ore t han o thers. W rite a program t o a utomatically c ollect t erms r elated t o s tock m arket (e.g. s tock, s hare, f und), f or e xample, from t he W ikipedia p age o n s tock m arket (/wiki/Stock_market). C ount t heir frequencies i n t he T DT3 a rticles a nd a ssign q uery-‐independent w eights b etween 0 a nd 1 t o t he a rticles (cf. S ection 7.1.4 o f t he t extbook). R evise t he p rogram f rom 2.1 t o r erank t he r esults f rom t he L ucene index b y u sing t he q uery-‐independent w eights: F or e xample, c onsidering a q uery q, o ne o f i ts r esultant articles d, a nd t he o riginal s core o f d g iven b y L ucene, s core(q,d), y ou m ay a dd t he q uery-‐independent weight o f d, g(d), t o s core(d) t o o btain t he n ew s core o f d, s core’(q,d), a s f ollows:score’(q,d) = s core(q,d) + g(d)Find e xample q ueries w hose t op 20 d ocuments a re a ffected b y t he r eranking a nd t hose n ot a ffected. Discuss i f t he r eranking h elps u s a chieve t he g oal o f f ocusing o n s tock m arket a nd h ow t o i mprove i t.2.3 W rite a p rogram t hat t akes i n a m isspelled q uery, r uns t he b est s pell c orrector y ou w rote i n p art 1 o n this q uery t o s uggest a lternative s pellings, a nd q ueries t he L ucene i ndex u sing t he s uggested s pellings, printing o ut t he I Ds o f t op 20 d ocuments. S how o utput o f y our s ystem w here t he s pell c orrection d oes well a nd w here i t d oes p oorly. L ucene a lso h as a s pell c hecker. W rite a nother p rogram t hat u ses t he Lucene S pellChecker. C ompare t he r esults w ith t hose o f t he b est s pell c orrector f rom p art 1. W hich i s better a nd w hy? H ow c an y our e ngine b e i mproved?Credit f or a dvanced (10 p oints):Implement s ome o f y our s uggestions f or i mprovement f rom 2.2 a nd 2.3. T he q uality o f y our i dea, implementation, a nd w riteup w ill a ll b e c onsidered.References:•Lucene: h ttp:///java/docs/index.html•Information R etrieval a nd W eb S earch c ourse a t S tanford U niversity (source o f t his a ssignment): /class/cs276/•Topic D etection a nd T racking (TDT) P hase 3 (source o f t he T DT3 c orpus):/TDT3/Resource f iles p rovided a t t he c ourse s ite:•SpellingCorrector.java, S pellingScorer.java: A s m entioned a bove•big.txt: A c ollection o f d ocuments f rom w hich y ou m ay c ollect d ictionary w ords•spelltest1.txt, s pelltest2.txto Test d ata f iles f or s pelling c orrection, w here e ach l ine f ollows t he f ormat “a d ictionary word : a l ist o f i ncorrectly s pelled w ords”•tdt3.zip: A n ews a rticle c ollection。
Assignments 1 and 2 MATS4004 2013(1)
2013 MATS4004: Assignment 1 : Hard copy Due Monday Week 8 [Total marks = 10 marks]1.Write a 2 page quantitative analysis of your understanding of Plane Stress and Plane Strainmode I fracture phenomenon in terms of the stress and strain components and physical nature of the deformation. Use diagrams as relevant.(3 marks)2.Calculate both plane stress and plane strain mode I fracture toughness value of a material whichhas Gc values of 25 kJ per square metre, Poisson’s ratio 0.33, and modulus of elasticity 70 GPa(2 marks)3.Calculate K I value for a specimen which has a∙width of 100 mm∙under a uniform tensile stress of 30 MPa∙2a = 20 mm∙under the following conditionsa)Centre crackb)Single Edge Notch Crackc)Double Edge Notch Crack(3 marks)2. Calculate K I value for a specimen with thickness 20 mm, W = 100 mm, and applied Load of 10 KNa)In the Compact Tension form with 2a = 20 mm, andb) Under 3-point bending with 2a = 20 mm,a span of 120 mm,thickness 20 mm,W = 100 mm, andapplied Load of 10 KN(2 marks)---------------------------------------------------------------------------------------------------------------------------- 2013 MATS4004: Assignment 2 : Hard copy Due Monday Week 11 [Total marks = 10 marks] INDIVIDUAL Topic [different case study for each student]:2000 words plus Figures and Tables: 10 marksDiscuss a practical case of catastrophic fracture of a structure/ engineering component analysing:a)How did the accident happen; (4 marks)b)How the accident could have been prevented, and / or loss of life avoided. (4 marks)c)Any recommendation from you to prevent such event in the future (2 marks)。
solutions for assignment5
Chapter 5+6+8 AssignmentsP5.Consider the 5-bit generator, G= 10011, and suppose that D has the value 1010101010. What is the value of CRC?Solution:If we divide 10011 into 1010101010 0000, we get 1011011100, with a remainder of R=0100.P21. Suppose nodes A and B are on the same 10Mbps Ethernet bus, and the propagation delaybetween the two nodes is 245 bit times. Suppose A and B send frames at the same time, the frames collide, and then A and B choose different values of K in the CSMA/CD algorithm. Assuming no other nodes are active, can the retransmissions from A and B collide? For our purposes, it suffices to work out the following example. Suppose A and B begin transmission at t =0 bit times. They both detect collisions at t =245 bit times. They finish transmitting a jam signal at t = 245 + 48 = 293 bit times. Suppose K A =0 and K B = 1. At what time does B schedule its retransmission? At what time does A begin transmission? (Note: The nodes must wait for an idle channel after returning to Step 2 -- see protocol.) At what time does A's signal reach B? Does B refrain from transmitting at its scheduled time?Solution:Because A's retransmission reaches B before B's scheduled retransmission time (805+96), B refrains from transmitting while A retransmits. Thus A and B donot collide. Thus the factor 512 appearing in the exponential backoff algorithm is sufficiently large.P23. Suppose four nodes, A, B, C, and D, are all connected to a hub via 10Mbps Ethernet cables.The distances between the hub and these four nodes are 300m, 400m, 500m, and 700m, respectively. Recall that the CSMNCD protocol is used for this Ethernet. Assume that the signal propagation speed is 2*108m/sec.a. What is the minimum required frame length?b. If all frames are 1500 bits long, find the efficiency of this Ethernet.Solution:a). minimum required frame length is given by2*d prop* BW=2*(500+700)/( 2 108) * 10 * 106=120 bits.There is no maximum required packet length.b). Efficiency is given by1/(1+5* d prop/ d trans) =1/(1+5*120/2/1500 )=0.83P37. In this problem, you will put together much of what you have learned about Internetprotocols. Suppose you walk into a room, connect to Ethernet, and want to download a web page. What are all the protocol steps that take place starting from powering on your PC to getting the web page? Assume there is nothing in our DNS or browser caches when you power on your Pc. (Hint: the steps include the use of Ethernet, OHCP, ARP, ONS, TCP, and HTTP protocols.) Explicitly indicate in your steps how you obtain the IP and MAC addresses of a gateway router.Solution:(The following description is short, but contains all major key steps and key protocols involved.)Your computer first uses DHCP to obtain an IP address. You computer first creates a special IP datagram destined to 255.255.255.255 in the DHCP server discovery step, and puts it in a Ethernet frame and broadcast it in the Ethernet. Then following the steps in the DHCP protocol, you computer is able to get an IP address with a given lease time.A DHCP server on the Ethernet also gives your computer a list of IP addresses of first-hop routers, the subnet mask of the subnet where your computer resides, and the addresses of local DNS servers (if they exist).Since your computer’s ARP cache is initially empty, your computer will use ARP protocol to get the MAC addresses of the first-hop router and the local DNS server.Your computer first will get the IP address of the Web page you would like to download. If the local DNS server does not have the IP address, then your computer will use DNS protocol to find the IP address of the Web page.Once your computer has the IP address of the Web page, then it will send out the HTTP request via the first-hop router if the Web page does not reside in a local Web server. The HTTP request message will be segmented and encapsulated into TCP packets, and then further encapsulated into IP packets, and finally encapsulated into Ethernet frames. Your computer sends the Ethernet frames destined to the first-hop router. Once the router receives the frames, it passes them up into IP layer, checks its routing table, and then sends the packets to the right interface out of all of its interfaces.Then your IP packets will be routed through the Internet until they reach the Web server.The server hosting the Web page will send back the Web page to your computer via HTTP response messages. Those messages will be encapsulated into TCP packets and then further into IP packets. Those IP packets follow IP routes and finally reach your first-hop router, and then the router will forward those IP packets to your computer by encapsulating them into Ethernet frames.Additional 1: Please answer the following question after reading Chapter 6 and referring tothe ftp:///chapt6.pdf . What are MAC methods for WiFi, Bluetooth, WiMax and Cellular network respectively? What are RDT approaches for WiFi, Bluetooth, WiMax and Cellular network respectively? error detection + retransmisstion or error correction?Solution:The following table summarizes the wireless MAC and RDT technologies. Each needs to be explained in detail.Additional 2:Why WiFi can’t CSMA/CD?Solution:Because Collisions Detection is difficult for WiFi:∙hidden terminal problem !∙difficult to sense because of fading∙Most radios are half duplexAdditional 3: Please explain how public key cryptography RSA is used in email security protocol: PGP (Pretty Good Privacy). Please refer to Chapter 8Solution:Step 1: Calculate hash (MD5) of message H(m). => you’ve got the digest of the messageStep 2: Encrypt H(m) with Alice’s private key => you’ve got Alice’s signature.Step 3: Append signature to text, then encrypt it with shared key Ks.Step 4: Encrypt shared key Ks with Bob’s public key, then append to the cipher text of step 2 => Bob can get the Ks.Step 5: The result message of step 4 is converted to base64 and be put into an RFC 822 body and be expected to arrive unmodified.D2 (don’t submit) Many of the functions of an adapter can be performed in software that runs onthe node's CPU. What are the advantages and disadvantages of moving this functionality from the adapter to the node?。
Assignment1_solution_2014
COMP 7390Assignment 1 SolutionDue: 6:30pm, Oct 22, 2014Submit to your instructor at the beginning of class.Please submit handwritten version, except for Problem 5.You must show all equations that you have used.1a. An insurance company needs to payout $5 million 5 years from now. If the company can invest money at an annual rate of 5% compounded semiannually, how much money should the company invest now?Ans: Let $A be the amount the company invests now. ThenAA∗�1+0.052�(2∗5)=5∗106Hence AA=3.90599∗106.1b. An insurance company needs to payout $10 million 10 years from now. If the company can invest money at an annual rate of 5% compounded semiannually in the first 5 years, and at an annual rate of 6% compounded semiannually in the second 5 years, how much money should the company invest now?Ans: Let $A be the amount the company invests now. ThenAA∗�1+0.052�(2∗5)∗�1+0.062�(2∗5)=10∗106Hence AA=5.81285∗106.2. You invest $100,000 in fixed deposit at a bank on Jan 1, 2010. In the next 10 years, youinvest $10,000 at the end of every June and $20,000 at the end of every December in fixed deposit also. Assume that throughout the period, the annual interest rate is 8%, payablesemiannually. If all interest payments are reinvested at the same rate, what is the futurevalue of your account at the beginning of Jan 1, 2020?Ans: FFFF=$100,000∗�1+0.082�(2∗10)+$10,000∗�1+0.082�19+$20,000∗�1+0.082�18+ +$10,000∗�1+0.082�17+$20,000∗�1+0.082�16+⋯+$10,000∗�1+0.082�+ $20,000=$100,000∗�1+0.082�(2∗10)+$10,000∗�1+0.082�∗��1+0.082�18+�1+0.082�16+⋯+1�+$20,000∗��1+0.082�18+�1+0.082�16+⋯+1�=$100,000∗�1+0.082�(2∗10)+�$10,000∗�1+0.082�+$20,000�∗��1+0.082�18+�1+0.082�16+⋯+1�=$100,000∗�1+0.082�(2∗10)+�$10,000∗�1+0.082�+$20,000�∗(1−�1+0.082�20)(1−�1+0.082�2) =$662,8643. You put down $100,000 in an amortized investment on Jan 1, 2010. (Recall: amortizationis a method of repaying a loan through regular payments of interest and principal.) The investment pays you $C at the end of every June and $2C at the end of every December for10 years, and the annual yield to maturity is 8%, compounded semiannually. What is thevalue of $C?Ans: We solve$100,000=CC (1+0.082 )−1+2CC (1+0.082 )−2+CC (1+0.082 )−3+2CC (1+0.082 )−4+⋯+ CC (1+0.082 )−19+2CC (1+0.082 )−20=CC(1+0.082 )−1�1+�1+0.082�−2+⋯+�1+0.082�−18�+2CC(1+0.082 )−2�1+�1+0.082�−2+⋯+�1+0.082�−18�=CC[�1+0.082�−1+2�1+0.082�−2]�1+�1+0.082�−2+⋯+�1+0.082�−18�=CC[�1+0.082�−1+2�1+0.082�−2][1−�1+0.082�−20][1−�1+0.08�−2]Hence CC=$4,937.72.4. Three banks quote consumer loans at the following rates:(a) Bank 1: 10%, quarterly compounding,(b) Bank 2: 9.95%, monthly compounding,(c) Bank 3: 9.9%, continuous compounding.Which bank’s interest rate is highest?Ans: It is important that we compare the 3 loans on equal compounding scheme. We mayconvert each case to continuous compounding. The equivalent continuous compounding rate for each bank is:(a) Bank 1: solving (1+0.14)4=ee rr 1, we get rr 1=9.87705%.(b) Bank 2:solving (1+0.099512)12=ee rr 2, we get rr 2=9.90898%.(c) Bank 3: already given to be 9.9%.Hence Bank 2’s interest rate is highest. 5. (a) A home buyer takes out a 15-year $1,000,000 adjustable-rate mortgage (ARM). Theinitial interest rate is 6%. What is the initial monthly payment?Using Excel or any programming language, print out the first 12 months of the payment schedule.(b) Suppose that after 6 months, the interest rate is changed to 5.75%. What is the newmonthly payment?Print out another 12 months of the new payment schedule, starting from the 7th month.Ans: (a) Let the monthly payment be C. The bank may consider the payments as a generalordinary annuity with n=15, m=12, r = 0.06. The PV of this annuity must be equal to the loan amount, which is $1,000,000. ThereforePPFF =$1,000,000=CC ∗�1−�1+rr mm �−nn∗mm��rr �=CC ∗[1−(1+0.0612 )−15∗12](0.0612)s o that CC =$8,438.5683.(b) Let the new monthly payment be C2. The bank may consider the payments as a newgeneral ordinary annuity with 180−6=174 payments. The PV of this annuity mustbe equal to the remaining principal, which is $979,108.972. ThereforePPFF=$979,108.972=CC2∗[1−(1+0.057512 )−174 ](0.057512)s o that CC2=$8,307.814.6. The Wall Street Journal prints the following quotation for a T-Bill:MATURITY DAYS TO MAT BID ASKEDNov 12 09 29 0.055 0.048(a) What is the asked price of such a T-Bill with a face value of $10,000?(b) For how much can you sell this T-Bill with a face value of $10,000?(c) What is the actual yield as related to the asked price?Show all your derivations.Ans: (a) Asked yield = 0.048%; a dealer was willing to sell the bill at a discount from par value of:0.048%×29360=0.00386667%A bill with $10,000 par value could be purchased for$10,000×1(1+0.0000386667)=$9,999.61(b) Bid yield = 0.055%; a dealer would be willing to purchase the bill for$10,000×1(1+0.00055×29)=$9,999.56(c) Actual yield as related to asked price:Solving $10,000=$9,999.61×(1+29365yy), yy=0.049%.7a. A company issues a 10-year bond with par value $10,000 and a coupon rate of 8%, payable semiannually. The bond is callable at a price of $11,200, $11,000, …, $10,200 after year 4, 5, …, 9, respectively. Find the price that guarantees a yield of 10.5% compoundedsemiannually for the investor, regardless of how many years the bond is held. Ans: The coupon interest is $10,000∗0.082=$400.If the bond is called after 4 years, the PV that guarantees a return of 10.5% is$400∗[1−(1+0.1052)−2∗4](0.105) + $11,200[1+�0.105�]2∗4=$9,997.1If the bond is called after 5 years, the PV that guarantees a return of 10.5% is$400∗[1−(1+0.1052)−2∗5]�0.1052� + $11,000�1+�0.105��2∗5=$9,645.88Similarly, if the bond is called after 6, 7, …, 9 years, the PV’s that guarantee a return of10.5% are, respectively,$9,340.49, $9,075.33, $8,845.47, $8,646.55Lastly, if the bond is held to maturity, the PV that guarantees a return of 10.5% is$400∗[1−(1+0.1052)−2∗10](0.105) + $10,000[1+�0.105�]2∗10=$8,474.72If one pays more than $8,474.72, and if the bond is held to maturity, then the yield is less than 10.5% compounded semiannually.7b. A 20-year bond with par value $10,000 and annual coupon rate 6% (paid quarterly) sells for $11,200 and is callable in 10 years at a call price of $11,800. What are the bond’s yield to maturity and yield to call?Ans: From the following Excel file, yield to maturity = 5.04%, yield to call = 5.76%.8. Suppose you buy a 20-year, 8% (semiannual payment) coupon bond with face value$10,000 for $11,000 and intend to hold it for 5 years. You forecast that the bond’s yield to maturity will be 9% when the bond is sold, and that the annual reinvestment rate on the coupons will be 7.5% (compounded semiannually). What is the estimated annualizedcompound return on your investment?Ans: At the end of the holding period, the bond will have 15 years remaining until maturity. The forecasted sales price (using yield to maturity=9%) will be, using CC=$10,000×8%2= $400,yy=9%,nn=15,mm=2,FF=$10,000,PPFF=CC[ 1−�1+yy mm�−(nn∗mm)](yy)+FF(1+yy)(nn∗mm)=$9,185.56The 10 coupon payments will grow with compound interest to, with CC=$400,rr= 0.075,mm=2,nn=5,FFFF=CC(1+rr mm)nn∗mm−1+CC(1+rr mm)nn∗mm−2+⋯+CC=CC��1+rr mm�nn∗mm−1rr�=$4,747.14Hence the $11,000 initial investment will grow to $9,185.56+$4,747.14=$13,932.7 in5 years.The estimated annualized compound return rr cc is calculated by$11,000×(1+rr cc2)5×2=$13,932.7, giving rr cc=4.78%.----- THE END -----。
Solutions (1)
STATS331,Assignment1,2013SolutionsAugust19,2013Question1a)Here is the Bayes’Box.The rows correspond to the hypotheses S(the email is spam) and¯S(the email is not spam).Hypotheses prior likelihood prior×likelihood posterior S0.50.050.0250.9804¯S0.50.0010.00050.0196 Totals:10.02551b)The top row of the Bayes’Box is equivalent to:P(S|N)=P(S)P(N|S)P(N)(1)orP(S|N)=P(S)P(N|S)P(S)P(N|S)+P(¯S)P(N|¯S)(2)The difference is the expanded version of the marginal likelihood,calculated by using the sum rule(or knowing that it is the sum of prior×likelihood).You could have also given the second row which would be the same but with S and¯S swapped.c)I repeated the Bayes’Box,the only difference being the likelihood P(N|¯S)and the sub-sequent numbers.Note that in this case,the presence of the word Nigeria is evidence that the email is not spam!People often worry about the choice of prior affecting things,but the likelihood can also affect things,and the likelihood is also based on prior information about the meaning of the data.Hypotheses prior likelihood prior×likelihood posterior S0.50.050.0250.3333¯S0.50.10.00050.6667 Totals:10.0751d)The marginal likelihood is the probability of the data,in this case,the probability that an email would say“Nigeria”.This can happen either with S or¯S,and the probability of it occurring via the“spam”route is the same for both people.However,the immigrant hasa higher probability of getting Nigeria in a non-spam email,so the marginal likelihood is higher.In maths,the marginal likelihood comes from the sum rule used with the product rule:P(N)=P(S)P(N|S)+P(¯S)P(N|¯S)(3) and the difference comes in P(N|¯S)which is higher for the immigrant.As everything is positive,the result is higher.Question2a)The three hypotheses are mutually exclusive and exhaustive.Oliver’s innocence is implied if either H2or H3is true,so the prior probability of innocence can be obtained with a simple use of the sum rule:P(innocent)=P(H2or H3)(4)=P(H2)+P(H3)(5)=0.5+0.3(6)=0.8.(7) which is also equal to1−P(H1).b)Similar to above.“Oliver was at the scene”is true if either H1or H2is true.P(at scene)=P(H1or H2)(8)=P(H1)+P(H2)(9)=0.7.(10) c)The Bayes’Box is given below.The three hypotheses are already mutually exclusive and exhaustive so can go right into the Bayes’Box without modification.The prior probabilities were also given in the question.The likelihoods come from the following reasoning:H1:if Oliver is guilty then the probability that the blood would be type“O”is 100%.H2and H3:if Oliver is innocent then the blood is of someone else,the probability it will be type“O”is0.6.Note that the posterior probabilities aren’t that different from the prior probabilities.This information doesn’t help that much in telling which of H1, H2,and H3is correct.Hypotheses prior likelihood prior×likelihood posterior H10.210.20.294H20.50.60.30.441H30.30.60.180.265Totals:10.681d)This is exactly the same as part b)but you use the posterior instead of the prior.P(at scene|D)=P(H1or H2|D)(11)=P(H1|D)+P(H2|D)(12)=0.7353.(13)Note that this is only slightly higher than the prior probability in part b).The data provided very slight evidence that Oliver was at the scene.e)The same Bayes’Box can be constructed but the likelihoods for H2and H3are now different.This is because the probability offinding AB blood given that the suspect is not guilty(i.e.for both H2and H3)is now0.01instead of0.6.Hypotheses prior likelihood prior×likelihood posterior H10.210.20.9615H20.50.010.0050.0240H30.30.010.0030.0144Totals:10.2081Yes,they chose to give a guilty verdict as0.9615≥0.95.Question3This question involves manipulating probability distributions in R.It is most useful for parameter estimation problems involving a single parameter.a)There are several ways.One is u=seq(1,100)and another is u=1:100.You could even do it with a loop,although that wouldn’t be the fastest or most elegant way.b)Here is the code I used.Anything equivalent will do.prior=1/uprior=prior/sum(prior)c)Here is the code I used to make the plot.Anything equivalent will do.plot(u,prior,xlab=’u’,ylab=’Prior Probability’)and here is myplot:prior_mean=sum(u*prior)prior_sd=sqrt(sum(u^2*prior)-prior_mean^2)#These are19.28and24.53e)The probability of u≥10can be found by summing the probabilities in the prior vector,but only including those elements where the value of the u vector is greater thanor equal to10.There are a couple of ways,here’s my favourite.prob1=sum(prior[u>=10])#Sum the subset of the prior vector where u>=10 prob2=sum(prior[u>=50])#Sum the subset of the prior vector where u>=50 #These are0.45and0.13Since the u values are1,2,3,...,100,it is also valid to do,for example,sum(prior[10:100]), although this is less general.f)This involves re-making the prior vector to be uniform,and then repeating part e) using the new prior vector.Here’s my code:prior=rep(1,length(u))prior=prior/sum(prior)prob1=sum(prior[u>=10])prob2=sum(prior[u>=50])#These are0.91and0.51Question4a)The pasted output should look like this.Loading required package:codaLoading required package:latticeLinked to JAGS3.3.0Loaded modules:basemod,bugsCompiling model graphResolving undeclared variablesAllocating nodesGraph Size:5Initializing model|**************************************************|100%|**************************************************|100%b)The code is plot(results$theta,type=’l’)and the plot looks like this:c)The code is hist(results$theta,breaks=100)and the plot looks like this:c)This is easily calculated using mean(results$theta).JAGS doesn’t respect set.seed, which I didn’t realise.The resulting value should be somewhere close to3/7.d)The changed line should look like:draw=jags.samples(m,1000000,thin=1,s=c(’theta’))and the new histogram should look much smoother,very similar to the analytical posterior from the notes(except this is a histogram of samples,not evaluations of the density function):e)I got0.428541using mean(results$theta).The markers were instructed to use a tolerance from0.427to0.43.。
HW 1
Homework Assignment 1InstructionsThis assignment is due to be turned in at the start of class on Monday February 6. You can work on this assignment by yourself or in a team of two. If you choose to work in a team of two, you should turn in only one assignment per team (with both member’s student IDs on the assignment).The assignment consists of two parts. Part A contains discussion questions. These are NOT to be turned in, they are intended to solidify your understanding of the theoretical concepts that we have discussed. I suggest writing down your answers and comparing them with the solutions that I will upload once the assignments have been turned in. Part B contains assignment problems that must be turned in. Remember that these assignments are graded on a √- ,√, √+ system as detailed in the syllabus. You are free to turn in printouts or a clear, legible, handwritten assignment. Where I have drawn problems form the text-book, I have indicated the corresponding problem number in the text.Part A: Discussion questions (not to be turned in).1.Problem 1.2. Explain carefully the difference between hedging, speculation, and arbitrage.2.Problem 1.3. What is the difference between entering into a long forward contract whenthe forward price is $50 and taking a long position in a call option with a strike price of $50?3.Problem 1.4.Explain carefully the difference between selling a call option and buying aput option.4.Problem 1.18. A US company expects to have to pay 1 million Canadian dollars in 6months. Explainhow the exchange rate risk can be hedged using (a) a forward contract and (b) an option.5.Why do futures contracts have margins?6.Problem 2.1. Distinguish between the terms open interest and trading volume.7.Explain what is meant by basis risk when futures contracts are used for hedging.8.Problem 3.3.Explain what is meant by a perfect hedge. Does a perfect hedge always leadto a better outcome than an imperfect hedge? Explain your answer.9.Problem 3.13. “If the minimum-variance hedge ratio is calculated as 1.0, the hedge mustbe perfect." Is this statement true? Explain your answer.Part B: Homework problems (to be turned in)1. A trader enters into a one-year short forward contract to sell an asset for $60 when thespot price is $58. The spot price in one year prov es to be $63. What is the trader’s gain or loss?a.Show a dollar amount and indicate whether it is a gain or a loss.b.When is this money actually received or paid?c.How would your answers change if the trader bought a future instead of a forward?2. A trader buys a 1 year forward contract on the S&P 500 index at a price of 2100 and alsobuys a put on the S&P 500 index with a strike price of $2100 and a time to maturity of one year.a.Draw the payoff diagram for this combined positionb.What does this remind you of?c.What if the put cost $80. Ignoring the time value of money repeat part (a) above,taking into account the premium ($80)3.The current spot price of gold is $1280 per ounce. The forward price for 1 year deliveryis $1400. Suppose an investor can borrow at 3% per year (simple interest). How can the investor make a riskless profit (assuming there is no cost or benefit to storing gold)4. A refinery will buy 10,000 barrels of oil in March. The forward price for delivery inMarch is $45.5/barrel, and the prices of March call and put options with prices $46/barrel are $2.5 and $3 respectively. Assume that each forward and option contract is for 1000 barrelsa.Should the refinery buy or sell forwards to hedge their exposure? How manycontracts should the firm trade? Draw a payoff diagram showing how thefirm’s payoff change with the spot price in March for their underlying position,the forward contract, and their net position.b.Suppose the refinery trades half as many contracts as you assumed in part (a).Redraw the payoff diagrams and explain the intuitionc.If the refinery hedges using options, should it trade calls or puts? Buy or sell?How many contracts? Draw a payoff diagram showing how the firm’spurchase price (with and without hedging) varies with the spot price of oil inDecember. The payoff diagram should take into account the premium (butignore the time value of money)5.Suppose that you enter into a short futures contract to sell July silver for $17.20 perounce. The size of the contract is 5,000 ounces. The initial margin is $4,000, and the maintenance margin is $3,000. What change in the futures price will lead to a margin call? What happens if you do not meet the margin call?6. A company has a $20 million portfolio with a beta of 1.2. It would like to use futurescontracts on the S&P 500 to hedge its risk. The index futures is currently standing at 1080, and each contract is for delivery of $250 times the index. What is the hedge that minimizes risk? What should the company do if it wants to reduce the beta of the portfolio to 0.6?7.The standard deviation of monthly changes in the spot price of live cattle is (in centsper pound) 1.2. The standard deviation of monthly changes in the forward price of live cattle for the closest contract is 1.4. The correlation between the forward price changes and the spot price changes is 0.7. It is now October 15. A beef producer is committed to purchasing 200,000 pounds of live cattle on November 15. The producer wants to use the December live-cattle forward contracts to hedge its risk.Each contract is for the delivery of 40,000 pounds of cattle. What strategy should thebeef producer follow (long or short, how many contracts)?8.On July 1, an investor holds 50,000 shares of a certain stock. The market price is $30per share. The investor is interested in hedging against movements in the market over the next month and decides to use the September Mini S&P 500 futures contract. The index is currently 1,500 and one contract is for delivery of $50 times the index. The beta of the stock is 1.3. What strategy should the investor follow? Under what circumstances will it be profitable?。
fromproblemstosolutions教学设计
fromproblemstosolutions教学设计
教学设计:从问题到解决方案
一、教学目标
1. 知识目标:掌握解决问题的基本流程和方法。
2. 能力目标:能够运用所学知识解决实际问题,提高分析和解决问题的能力。
3. 情感态度价值观:培养团队合作意识,提高沟通协调能力。
二、教学内容
1. 问题识别:如何识别问题并明确问题的性质和范围?
2. 收集信息:如何收集与问题相关的信息和数据?
3. 分析问题:如何分析问题并提出解决方案的初步思路?
4. 方案实施:如何将解决方案付诸实践并评估其效果?
5. 反馈与改进:如何根据实施效果进行反馈和改进?
三、教学步骤
1. 导入新课:通过案例导入,引导学生认识到解决问题的重要性,并激发学习兴趣。
2. 讲授新课:讲解教学内容,通过实际案例和模拟训练帮助学生理解解决问题的方法和步骤。
3. 课堂练习:分组讨论并练习解决实际问题,巩固所学知识,提高运用能力。
4. 归纳小结:总结教学内容,强调解决问题的流程和要点,提醒学生需要注意的问题。
四、教学方法与手段
1. 教学方法:采用案例分析、小组讨论、角色扮演等多种教学方法,引导学生积极参与课堂活动,提高教学效果。
2. 教学手段:利用多媒体课件、实物展示等手段辅助教学,增强学生对知识的理解和记忆。
五、教学评价与反馈
1. 评价方式:采用多种评价方式,包括小组报告、个人作业、课堂表现等,全面评估学生的学习效果。
2. 反馈调整:根据学生反馈和评价结果,及时调整教学策略和方法,提高教学质量。
Assignment1Instruments
Assignment1InstrumentsInternational Financial Instruments Assignment No. 1ZhaoYan32015110096In this assignment, you are required to solve questions using textbook knowledge and analytical tools (financial calculator, EXCEL etc.). Each question accounts for equal marks in your grading. This is an individual assignment, plagiarism, once discovered, will be severely punished.You are required to submit an answer sheet report, on which you should indicate your name, class, student ID, and reasoning process and answers to each question in numerical order. The deadline of this assignment is May 12th, 2017. Questions (5 in total):1, One orange juice future contract is on 15,000 pounds of frozen concentrate. Suppose that in September 2014 a company sells a March 2016 orange juice futures contract for 120 cents per pound. In December 2014 the futures price is 140 cents; in December 2015 the futures price is 110 cents; and in February 2016 it is closed out at 125 cents. The company has a December year end. What is the company's profit or loss on the contract? How is it realized? What is the accounting and tax treatment of the transaction if the company is classified as a) a hedger and b) a speculator?a)This company can make profit or loss by buying future contract at the future market on 15000 pounds of frozen concentrate for the price at one time, this process called close out and the company get theprofit or loss which depend on the future pricewhen close out.Profit/loss:-5cents/pound*15000pounds=-75000cents=-750dollarsb) As a hedgerAccounting:-5cents/pound*15000pounds=-75000cents=-750dollarsTax treatment:As ordinary incomeAs a speculatorAccounting:1)2014 -20cents/pound*15000pounds=-300000cents=-3000dollars2)2015 30cents/pound*15000pounds=450000cents=4500dollars3)2016 -15cents/pound*15000pounds=-225000cents=-2250dollarsTax treatment:For the noncorporate taxpayer this gives rise to capital gain and losses that are treated as if they were 60%1long term and 40% short term without regard to the holding period.For a corporate taxpayer, capital gains are taxed at the same rate as ordinary income and the ability to deduct losses is restricted.2, The following table gives data on monthly changes in the spot price and the futures price for a certain commodity. Use the data to calculate a minimum variance hedge ratio.Descriptive StatisticsN Std. DeviationSPC 10 .49333FPC 10 .51156Valid N10(listwise)CorrelationsSPC FPCSPC Pearson Correlation 1 .981**Sig. (2-tailed) .000Sum of Squares and Cross-2.190 2.227productsCovariance .243 .247N 10 10FPC Pearson Correlation .981** 1Sig. (2-tailed) .000Sum of Squares and Cross-2.227 2.355productsCovariance .247 .262N 10 10**. Correlation is significant at the 0.01 level (2-tailed).H= Correlation *SD(SPC)/SD(FPC)=0 .981*0.49333/0.51156=0.9463, A fund manager has a portfolio worth $50 million with a beta of 0.87. The manager is concerned about the performance of the market over the next two months and plans to use three-month futures contracts on the S&P 500 to hedge the risk. The current level of the index is 1250, one contract is on 250 times the index, the risk-free rate is 6% per annum, and the dividend yield on the index is 3% per annum. The current 3 month futures price is 1259.a)What position should the fund manager take to eliminate all exposure to the market over the nexttwo months?b)Calculate the effect of your strategy on the fund manager’s returns if the level of the market intwo months is 1,000, 1,100, 1,200, 1,300, and 1,400. Assume that the one-month futures price is0.25% higher than the index level at this time. (Hint: to find out portfolio return, use CAPM:expected portfolio return = R F+ β(R M-R F).)a)N=beta*Va/Vf=0.87*50,000,000/(1250*250)=138.2b)4, The following table gives the prices of bondsa)Calculate zero rates for maturities of 6 months, 12 months, 18 months, and 24 months.b)What are the forward rates for the periods: 6 months to 12 months, 12 months to 18 months, 18 months to 24 months?c)What are the 6-month, 12-month, 18-month, and 24-month par yields for bonds that provide semiannual coupon payments?d)Estimate the price and yield of a two-year bond providing a semiannual coupon of 7% per annum.a)6month:100=98e^0.5R R=12month:100=95e^R R=18month:101=3.1*98/100+3.1*95/100+103.1*e^1.5R R=24month:104=4*98/100+4*95/100+4*e^-1.5R+104*e^-2Q Q=>BondPrincipal<-c(100,100,100,100)>TimetoMaturity<-c(0.5,1,1.5,2)>AnnualCoupon<-c(0,0,6.2,8)>BondPrice<-c(98,95,101,104)> DATA<-list(BondPrincipal,TimetoMaturity,AnnualCoupon,BondPrice)> ZeroRate1<-c(2*log(100/98))> ZeroRate2<-c(log(100/95))> ZeroRate3<-c(-log((101-3.1*exp(-0.5*ZeroRate1)-3.1*exp(-1*ZeroRate2))/103.1)/1.5)> ZeroRate4<-c(-log((104-4*exp(-0.5*ZeroRate1)-4*exp(-1*ZeroRate2)-4*exp(-1.5*ZeroRate3))/104)/2)>> ZeroRate1[1] 0.04040541> ZeroRate2[1] 0.05129329> ZeroRate3[1] 0.05442905> ZeroRate4[1] 0.05808545forwardrates612=2Zerorate2-Zerorate1forwardrates1218=3Zeroraye3-2Zerorate2+forwardrates1824=4Zeroraye4-3Zerorate3> 2*ZeroRate2-ZeroRate1[1] 0.06218117> 3*ZeroRate3-2*ZeroRate2[1] 0.06070055> 4*ZeroRate4-3*Zer[1] 0.06905465c)c=(100-100d)m/A=5.8507%d)3.5*e^(-4.08%*0.5)+3.5*e^(-5.12%*1)+3.5*e^(-5.44%*1.5)+103.5*e^(-5.80%*2)=102.135, A stock is expected to pay a dividend of $1 per share in two months and in five months. The stock price is $50, and the risk-free rate of interest is 8% per annum with continuous compounding for all maturities. An investor has just taken a short position in a six-month forward contract on the stock.a) What are the forward price and the initial value of the forward contract?b)Three months later, the price of the stock is $48 and the risk-free rate of interest is still 8% perannum. What are the forward price and the value of the short position in the forward contract? a)I=e^(-0.08*7/12)=1.954F=(50-I)*e^(0.5*0.08)=50.008IV=0b)K=FI=e^(-0.08*2/12)=0.987F=(48-I)*e^(0.08*3/12)=47.963V=K*e^(-0.08*3/12)-48+0.987=2.01。
SOLUTION Assignment 1 (1)
Part 1: How is National Income Distributed to the Factors of Production?1. The Neoclasical theory of distribution:a. Was developed by Karl Marxb.Is rejected by most economists todayc.Shows that the national income of an economy is not equal to total outputd.Is a theory of how national income is divided among the factors of production2. The price received by each factor of production for its services is determined by:a.Demand for output and supply of factorsb.Demand for factors and supply of factorsc.Demand and supply of outputd.Demand and supply of factors3. When factor supply is fixed and quantity of the factor is graphed on the horizontal axis whilefactor price is graphed on the vertical axis, the factor:a.Supply curve is horizontalb.Supply curve is verticalc.supply curve has a positive sloped.demand curve slopes to the right4. The real wage will increase if:a.The supply of labor increasesb.The productivity of labor increasesc.The price of output increasesd.The supply of capital decreases5. Suppose that the production function we are using is set as Cobb-Doublas function:Y = AK 0.5 L 0.5 and that A is 100 K is 80 and L is 100. Find the following:a.How much product that this economy produce?Y = 100 x 80 0.5 x 100 0.5 = $8944.3b.What are the wage and the rental price of land?The real wage or W/P = MPL = 0.5 x 100 x 8.94 / 10 = 44.72The real rent of capital = MPK = 0.5 x 100 x 10 /8.94= $55.92c.What share of output does labor receive?Labor receives 0.5 and capital also receives 0.5d.If a plague kills half the population, what is the new level of output?The new production function in this case will be:Y2 = AK0.5 (0.5L 0.5) = 100 x 8.94 x7.07 = $6321.53e.What share of output does labor receives now?Labor still receives 0.5 of output = 0.5 x $6321.53 = $3160.76Part 2: What Determines the Demand for Goods and Services?6. Consumption depends ___________ on disposable income, and investment depends____________ on the real interest rate:a.Positively, negativelyb.Positively, positivelyc.Negatively, negativelyd.Negatively, positively7. If the consumption function is given by the equation C = 500 + 0.5Y, the production function is Y= 50K 0.5 L 0.5, where K =100 and L = 100, then C equals:Y = 50 x 10 x 10 = 5000C = 500 + 0.5(5000) = 2500 + 500 = $3000a. 1000b.2500c.3000d.5000Part 3: What gives the Supply and Demand for Goods and Services into Equilibrium?8.You have that Y = C(Y-T) +I(r) + G where Y, T and G are fixed. The equilibrium level of whichvariable can be obtained here:a. Incomeb.Consumptionernment expenditured.The interest rate9.If income is 4800, consumption is 3500, government spending is 1000 and taxes minus transfersare 800, private savings is:Private Savings = Disposable income - Consumption = 4800 –800 – 3500 = 500a.300b.500c.1000d.130010. Assume equilibrium GDP (Y) is 5,000. Consumption (C) is given by the equationC = 500 + 0.6(Y-T). Taxes are equal to 600. Government spending is equal to 1000. Investmentis given by the equation I = 2160 – 100r, where r is the real interest rate in percent. In this case, the equilibrium real interest rate is:Y = C + G + IC = 500 + 0.6(5000-600) = 3140I = Y – C – G = 5000 – 3140 -1000 = 860860 = 2160 – 100(r) r = 0.13a. 5%b.8%c.10%d.13%。
trivial solutions的意思
trivial solutions的意思
"trivial solutions"是一个数学术语,用于描述在解决方程或问题时,显得非常简单和显而易见的解决方案。
这些解决方案通常是在问题中所给的条件或约束下可以轻松得出的结果。
在数学中,一个问题可能有多个解,其中一些解是非常特殊或平凡的,也就是所谓的"trivial solutions"。
这些解可能是显而易见的,或者是通过简单的代数运算即可得到的。
举例来说,考虑一个一元二次方程aa^2 + aa + a = 0。
其中a、a和a是已知的常数。
当a=0时,方程变成了一个一次方程,解可以直接通过代数运算得到。
这样的解被认为是"trivial solution",因为它很容易得到且不需要复杂的数学推理。
另一个例子是在线性方程组中找到"trivial solutions"。
考虑一个由多个线性方程组成的方程组,如果所有的未知数都等于零时,方程组成立,这也是一个"trivial solution"。
因为这个解是显而易见的,不需要进行任何计算。
需要注意的是,尽管"trivial solutions"在数学中通常被认为是简单和显然的解决方案,但在特定的上下文中,它们也可能具有重要的意义。
在某些情况下,"trivial solutions"可能是其他更复杂解的特殊情况或极限情况。
因此,无论是在数学还是其他学科中,理解"trivial solutions"的概念对于全面理解和解决问题都是重要的。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
by a direct link of R = 2 Mbps. Suppose the propagation speed over the link is 2.5 x108 meters/sec. a. Calculate the bandwidth-delay product, R x d prop b. Consider sending a file of 800,000 bits from Host A to Host B. Suppose the file is sent continuously as one large message. What is the maximum number of bits that will be in the link at any given time? c. Provide an interpretation of the bandwidth-delay product. d. What is the width (in meters) of a bit in the link? Is it longer than a football field? e. Derive a general expression for the width of a bit in terms of the propagation speeds, the transmission rate R, and the length of the link m.
9 P Z PZ 2.74 3.286
0.997
when Z is a standard normal r.v. Thus P “21 or more users”
0.003
Problem 24: Suppose two hosts, A and B, are separated by 20,000 kilometers and are connected
1 P X j 21
j 1
120
120 X j 12 120 9 j 1 P X 21 P j 120 0.1 0.9 120 0.1 0.9 j 1
Solutions:
a) 20 users can be supported. b) p 0.1 .
120 n 120 n c) . n p 1 p
120 n 120 n d) 1 . n p 1 p n 0
Chapter 1 Assignments
Review 1: What advantages does TDM have over FDM in a circuit-switched network? Please
compare different multiplexing technologies used in Mobile phone system: TDM, FDM, CDM, and explain how 4G uses TDM or FDM.
Problem6: In this problem we consider sending real-time voice from Host A to Host B over a
packet-switched network (VoIP). Host A converts analog voice to a digital 64 kbps bit stream on the fl y. Host A then groups the bits into 56-byte packets. There is one link between Host A and B; its transmission rate is 2 Mbps and its propagation delay is 10 msec. As soon as Host A gathers a packet, it sends it to Host B. As soon as Host B receives an entire packet, it converts the packet's twobits to an analog signal. How much time elapses from the time a bit is created (from the original analog signal at Host A) until the bit is decoded (as part of the analog signal at Host B)?
The time required to transmit the packet is
56 8 sec= 224 sec. 2 10 6
Propagation delay = 10 msec. The delay until decoding is
7msec + 224 sec + 10msec = 17.224msec A similar analysis shows that all bits experience a delay of 17.224 msec.
Solutions:
TDM and FDM are two widely used multiple access techniques. FDM is older technique often used for analog signals whereas TDM is relatively a newer technique used for digital signals. TDM advantage over FDM is that it offers bandwidth saving with ATDM (allocate time slots on demand dynamically) and there is low interference between the signals that are being multiplexed. 4G uses TDM and FDM for multiplexing and duplexing. For TD-LTE, the receive channel and the transmit channel take turns (i.e. divide the time between them) on the same frequency band. The time divisions are asymmetric, meaning that more time-slots are allocated to data going from the tower to the phone than from the phone to the tower. Whereas for FD-LTE, two frequencies are allocated, one for the transmit channel and the other for the receive channel. Orthogonal frequency division multiple access (OFDMA) is the multiple access method used in the LTE downlink. The LTE uplink is based on the single-carrier frequency division multiple access (SD-FDMA) mode.
20
We use the central limit theorem to approximate this probability. Let X j be independent random variables such that P X j 1 p .
P “21 or more users”
Solutions:
Consider the first bit in a packet. Before this bit can be transmitted, all of the bits in the packet must be generated. This requires
56 8 sec=7msec. 64 10 3
Problem 7: Suppose users share a 3 Mbps link. Also suppose each user requires 150 kbps when
transmitting, but each user transmits only 10 percent of the time. (See the discussion of statistical multiplexing in Section 1.3.) a. When circuit switching is used, how many users can be supported? b. For the remainder of this problem, suppose packet switching is used. Find the probability that a given user is transmitting. c. Suppose there are 120 users. Find the probability that at any given time, exactly n users are transmitting simultaneously. (Hint: Use the binomial distribution.) d. Find the probability that there are 21 or more users transmitting simultaneously.