[SOLVED] 代写 algorithm Scheme statistic 2. Extend the bank account example in the slides with the following upgrade and new methods:

30 $

File Name: 代写_algorithm_Scheme_statistic_2._Extend_the_bank_account_example_in_the_slides_with_the_following_upgrade_and_new_methods:.zip
File Size: 1186.92 KB

SKU: 9740993935 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


2. Extend the bank account example in the slides with the following upgrade and new methods:
withdrawmodify this method so it prints a message showing what the balance is and how much less than the request it is i.e. Withdrawal not allowed since balance is x where x is the current balance of the account. if the request is larger than the balance.
accrueadd 1 year of simple interest to the balance. At first assume an interest rate of 1
setratechange the interest rate to the given argument, where 1 is represented as 0.01, not 1.
1

You may start with the following code which is essentially copied from the lecture slides:
define newaccount initialbalance
let balance initialbalance
define deposit f
set! balancebalance f
balance
define withdraw f
condf balanceInsufficient funds
else
set! balancebalance f
balance
define balinq balance
lambda method
cond eq? method deposit deposit
eq? method withdraw withdraw
eq? method balanceinquire balinq
3. Createtwobankaccountobjectsanddemonstratethatthebalanceandratecanbesetandmodified independently.
4. PseudorandomNumberGenerator,PRNGRandomlychosennumbersareoftenneededforcom puter simulations. Different methods have been devised for generating numbers that have prop erties of randomly chosen numbers. Because numbers generated by systematic methods are not truly random, they are called pseudorandom numbers. The most commonly used procedure for generating pseudorandom numbers is the linear congruential method. We choose four integers: the modulus m, multiplier a, increment c,and seed x0, with 2am, 0cm, and 0x0m. We generate a sequence of pseudorandom numbers xn, with 0xnm for all n, by successively using the recursively defined function
xn1axnc mod m
Most computers do use linear congruential generators to generate pseudorandom numbers. Often, a linear congruential generator with increment c0 is used. Such a generator is called a pure multiplicative generator. For example, the pure multiplicative generator with modulus 2311 and multiplier 7516, 807 is widely used. With these values, it can be shown that 2312 numbers are generated before repetition begins.
Pseudorandom numbers generated by linear congruential generators have long been used for many tasks. Unfortunately, it has been shown that sequences of pseudorandom numbers generated in this way do not share some important statistical properties that true random numbers have. Because of this, it is not advisable to use them for some tasks, such as large simulations. For such sensitive tasks, other methods are used to produce sequences of pseudorandom numbers, either using some sort of algorithm or sampling numbers arising from a random physical phenomenon.
Define a SCHEME object representing a pure multiplicative pseudorandom number generator, using the modulus and multiplier above, that provides the following operations:
next calculates and returns the next pseudorandom number 2

get retrieves the current pseudorandom number in the sequence
Your object creation function, prng should accept a value for the initial seed as well as the mini mum and maximum values desired for pseudorandom numbers. You can restrict the large numbers provided by the linear congruential generator by applying the modulo function to it with the size of the range of numbers required i.e. xnmodulomaxmin and shifting it up to the desired range by adding min . Your object should look something like,
define prng seed min max
let …

lambda method
cond eq? method next next
eq? method get get
;;internal prng variables
;;prng methods
;the dispatcher
3

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 algorithm Scheme statistic 2. Extend the bank account example in the slides with the following upgrade and new methods:
30 $