Assignment Chef icon Assignment Chef

Browse assignments

Assignment catalog

33,401 assignments available

[SOLVED] Cse2050 homework 02: oop & tdd

Figure 1: Class Hierarchy to Implement  c1 = Cat(‘Babs’)c1.speak()>>> ‘Babs says Meow!’c1 = Cat(‘Babs’)c1.speak() # should call Cat.speak()c1.reply() # should call Animal.reply()>>> ‘Babs says Meow!’>>> ‘Babs says Meow!’class Animal: “””Represents a non-specific animal””” def __init__(self, name=”It”): “””Instantiates a new animal with a name””” self.name = namedef speak(self): “””Allows for an error to be caught if speak is not defined elsewhere””” raise NotImplementedError(“Subclasses must implement this method”)def reply(self): “””Calls the speak method””” return self.speak()class Mammal(Animal): “””Represents a Mammal in animal kingdom””” def speak(self): return f”{self.name} says HuH!”class Primate(Mammal): “””Represents subclass of Mammals that are Primates””” def speak(self): return f”{self.name} says EE-EE-OOH-OOH”class ComputerScientist(Primate): “”””Represents a subclass of Primates that are Computer Scientists””” # speak is inherited from primate passclass Cat(Mammal): “””Represents a subclass of Mammals that are Cats.””” def speak(self): return f”{self.name} says Meow!”# Test Cat Initialization and speak method cat = Cat(“Wilbur”) assert cat.name == “Wilbur”, “Cat name initialization failed” assert cat.speak() == “Wilbur says Meow!”, “Cat speak method failed with the name Wilbur”# Test Animal reply method assert cat.reply() == “Wilbur says Meow!”, “Animal reply method failed using Cat instance with the name Wilbur”# Testing Mammal class mammal = Mammal(“Brittney”) assert mammal.name == “Brittney”, “Mammal name initialization failed” assert mammal.speak() == “Brittney says HuH!”, “Mammal speak method failed”# Testing Primate class primate = Primate(“George”) assert primate.name == “George”, “Primate name initialization failed” assert primate.speak() == “George says EE-EE-OOH-OOH”, “Primate speak method failed”# Testing ComputerScientist class cs = ComputerScientist(“Alice”) assert cs.name == “Alice”, “ComputerScientist name initialization failed” assert cs.speak() == “Alice says EE-EE-OOH-OOH”, “ComputerScientist speak method failed” This is where the bulk of your work will be for this assignment. Anticipate spending at least a few hours here if you are new to OOP and TDD, and consider breaking it up over a few days if your schedule allows.Card games are a classic application of OOP. They let us use composition (decks of cards contain several card objects) and inheritance (a hand of cards can be treated as a specialized deck). The diagram below shows the inheritance model and the specific instance variables and methods we’ll implement here.  Descriptions of attributes and methods are provided later in this document.Figure 2: (a) Class diagram and (b) attributes for each class. Inherited attributes are in blue.Create the classes above in a file called Cards.py.  Using the TDD approach, write unittests BEFORE you write your other code and place your unittests in a file called TestCards.py.  This includes any exceptions you should raise.  See the unittest basic example below for an illustration of how to test that an error is raised and read more about unittest (link).  Your final TestCards.py class should include 3 classes – one for each class you are trying to test: Structure your code based on OOP principles. Hand should inherit from Deck, and should not overload any methods unless it needs to.Every method (including your unittests) should have a docstring.When writing tests, create your own examples. Do not use any of the examples shown below.Some OOP relationships:The expected input/output of each method is defined below.  Most do what you would think intuitively. Before you start implementing code, review these guidelines:  >>> c1 = Card(3, ‘hearts’)>>> repr(c1)‘Card(3, ‘hearts’)’>>> print(c1)‘3 of hearts’’ >>> c2 = card(3, ‘spades’)>>> c1 < c2True>>> c3 = Card(4, ‘hearts’)>>> c3 < c2True  At a minimum, submit the following files:    import random class Card: def __init__(self, value, suit): self.value = value self.suit = suitdef __repr__(self): ”’Return the machine representation of the card”’ return f”Card({self.value!r}, {self.suit!r}”def __str__(self): ”’Return string representation of the card”’ return f”{self.value} of {self.suit}”def __lt__(self, other): ”’Compare Cards first by suit then by value”’ if self.suit == other.suit: return self.value < other.value return self.suit < other.suitdef __eq__(self, other): ”’Check if two cards are equal first by suit then by value”’ return self.value == other.value and self.suit == other.suitclass Deck: def __init__(self, values=range(1, 14), suits=(‘clubs’, ‘diamonds’, ‘hearts’, ‘spades’)): self.card_list = [] for suit in suits: for value in values: self.card_list.append(Card(value, suit))def __len__(self): “””Return the number of cards in the deck.””” return len(self.card_list)def sort(self): “””Sort the cards in the deck.””” self.card_list.sort()def __str__(self): “””Return a string representation of the deck.””” return ‘, ‘.join(str(card) for card in self.card_list)def shuffle(self): “””Shuffle the cards in the deck.””” random.shuffle(self.card_list)def draw_top(self): “””Remove and return the top card of the deck.””” if not self.card_list: raise RuntimeError(“Cannot draw from an empty deck”) return self.card_list.pop()class Hand(Deck): def __init__(self, cards=None): “””Initialize a hand with an optional list of cards.””” if cards is not None: self.card_list = cards else: self.card_list = []def __str__(self): “””Return a string representation of the hand.””” return ‘Hand: ‘ + ‘, ‘.join(str(card) for card in self.card_list)def play(self, card): “””Play a card from the hand.””” if card not in self.card_list: raise RuntimeError(f”Attempted to play {card} that is not in hand: {self}”) self.card_list.remove(card) return card from Cards import Card, Deck, Handimport unittestclass TestCard(unittest.TestCase): “””Class to evaluate the performance of Card class””” def test_card_init(self): “””Test the instantiation of a Card.””” card = Card(‘3’, ‘hearts’) self.assertEqual(card.value, ‘3’) self.assertEqual(card.suit, ‘hearts’)def test_card_repr(self): “””Test the machine representation of a Card.””” card = Card(‘3’, ‘hearts’) self.assertEqual(repr(card), “Card(‘3’, ‘hearts'”)def test_card_str(self): “””Test the human-readable representation of a Card.””” card = Card(‘3’, ‘hearts’) self.assertEqual(str(card), “3 of hearts”)def test_card_lt(self): “””Test the less-than comparison of two Cards.””” card1 = Card(‘3’, ‘hearts’) card2 = Card(‘4’, ‘hearts’) self.assertTrue(card1 < card2)def test_card_eq(self): “””Test the equality comparison of two Cards.””” card1 = Card(‘3’, ‘hearts’) card2 = Card(‘3’, ‘hearts’) self.assertTrue(card1 == card2)class TestDeck(unittest.TestCase): “””Class to evaluate the performance of Deck class””” def setUp(self): “””Set up a deck of cards for each test.””” self.deck = Deck()def test_deck_init(self): “””Test the initialization of a Deck.””” self.assertEqual(len(self.deck.card_list), 52)def test_deck_len(self): “””Test the length of the Deck.””” self.assertEqual(len(self.deck), 52)def test_deck_sort(self): “””Test the sorting of the Deck.””” self.deck.shuffle()  # Shuffle first self.deck.sort()  # Sort it in order self.assertEqual(self.deck.card_list[0].suit, ‘clubs’)  # Assume clubs self.assertEqual(self.deck.card_list[0].value, 1)  # Assuming clubs value 1def test_deck_str(self): “””Test the string representation of the Deck.””” deck_str = str(self.deck) self.assertIsInstance(deck_str, str) self.assertIn(‘of’, deck_str)def test_deck_shuffle(self): “””Test the shuffle method.””” original_deck = self.deck.card_list.copy() self.deck.shuffle() self.assertNotEqual(original_deck, self.deck.card_list)def test_deck_draw_top(self): “””Test drawing the top card from the Deck.””” top_card = self.deck.card_list[-1] drawn_card = self.deck.draw_top() self.assertEqual(top_card, drawn_card) self.assertEqual(len(self.deck), 51)class TestHand(unittest.TestCase): “””Class to evaluate the performance of Hand class””” def setUp(self): “””Create a Hand instance with some Cards for testing.””” self.hand = Hand([Card(3, ‘hearts’), Card(4, ‘diamonds’), Card(2, ‘spades’)])def test_hand_init(self): “””Test the initialization of Hand with a list of Cards.””” self.assertEqual(len(self.hand.card_list), 3, “Hand should be initialized with 3 cards”)def test_hand_len(self): “””Test the __len__ method to ensure it returns the correct number of cards.””” self.assertEqual(len(self.hand), 3, “Length of hand should be 3”)def test_hand_sort(self): “””Test the sort method to ensure the Hand is sorted correctly.””” self.hand.sort() self.assertEqual(self.hand.card_list[0].suit, ‘diamonds’, “First card should be of suit ‘diamonds'”) self.assertEqual(self.hand.card_list[0].value, 4, “First card should be 4 of diamonds”)def test_hand_str(self): “””Test the __str__ method for a correct string representation of the Hand.””” hand_str = str(self.hand) self.assertIsInstance(hand_str, str) self.assertIn(“4 of diamonds”, hand_str, “String representation of hand should contain ‘4 of diamonds'”)def test_hand_play(self): “””Test the play method by playing a card from the Hand.””” card_to_play = Card(4, ‘diamonds’) played_card = self.hand.play(card_to_play) self.assertEqual(played_card, card_to_play, “The played card should be the same as the card requested to play”) self.assertEqual(len(self.hand), 2, “The hand should have one less card after playing”)def test_play_card_not_in_hand(self): “””Test the play method raises an error if the card is not in the Hand.””” card_not_in_hand = Card(5, ‘hearts’) with self.assertRaises(RuntimeError): self.hand.play(card_not_in_hand)if __name__ == ‘__main__’: unittest.main() 

$25.00 View

[SOLVED] Cse2050 data structures and object-oriented design homework: 01

Letter frequency is the number of times letters of the alphabet appear on average in written language.  According to Wikipedia, in the English language, the character “e” appears most often, then the characters “t”, “a”, and “o”.In this assignment, you will implement a letter frequency calculator to find i) the total number of times each letter occurs in a text file and ii) a percentage that shows how common the letter is in relation to all the letters in the text file.You can import the string module in this assignment if you wish. Do not import any other modules, except for code that you write yourself.f = open(‘frost.txt’)for line in f:print(line, end=”)  # The text file has a newline# already at the end of each# line.f.close() Fire and IceSome say the world will end in fire, Some say in ice.From what I’ve tasted of desire I hold with those who favor fire.But if it had to perish twice,I think I know enough of hateTo say that for destruction ice Is also great And would suffice.-Robert Frostimport stringdef letter_count(file): ”’Counts the instances of each ascii character from a file and returns an alphabetized dictionary”’ with open(file) as f: count = {} #initializes new dictionary data = f.read() data = data.lower() #reads and forces all characters as lower case for char in data: if char in string.ascii_lowercase: count[char] = count.get(char, 0) + 1 #check a-z frequency with default value of 0 sorted_count = {} #initializes and sorts dictionary in alphabetical order for key in sorted(count): sorted_count[key] = count[key] return sorted_countdef letter_frequency(dict_letters): ”’Given a dictionary of letters and their values, returns the ratio or frequency of each character in relation to the others in an alphabetized dictionary”’ total = sum(dict_letters.values()) freqs = {} for letter, count in dict_letters.items(): freqs[letter] = count / total return freqsif __name__ == ‘__main__’: #first test frostdict = {‘a’: 13, ‘b’: 2, ‘c’: 6, ‘d’: 10, ‘e’: 23, ‘f’: 12, ‘g’: 2, ‘h’: 12, ‘i’: 23, ‘k’: 2, ‘l’: 6, ‘m’: 3, ‘n’: 9, ‘o’: 20, ‘p’: 1, ‘r’: 14, ‘s’: 14, ‘t’: 20, ‘u’: 5, ‘v’: 2, ‘w’: 8, ‘y’: 3} assert(letter_count(‘frost.txt’)) == frostdict #second test frostfreq = {‘a’: 0.06190476190476191, ‘b’: 0.009523809523809525, ‘c’: 0.02857142857142857, ‘d’: 0.047619047619047616, ‘e’: 0.10952380952380952, ‘f’: 0.05714285714285714, ‘g’: 0.009523809523809525, ‘h’: 0.05714285714285714, ‘i’: 0.10952380952380952, ‘k’: 0.009523809523809525, ‘l’: 0.02857142857142857, ‘m’: 0.014285714285714285, ‘n’: 0.04285714285714286, ‘o’: 0.09523809523809523, ‘p’: 0.004761904761904762, ‘r’: 0.06666666666666667, ‘s’: 0.06666666666666667, ‘t’: 0.09523809523809523, ‘u’: 0.023809523809523808, ‘v’: 0.009523809523809525, ‘w’: 0.0380952380952381, ‘y’: 0.014285714285714285} assert(letter_frequency(letter_count(‘frost.txt’))) == frostfreq “C:UsersartjsOneDrive – University of ConnecticutDocumentsSpring 24CSE 2050cse2050hw1.venvScriptspython.exe” “C:UsersartjsOneDrive – University of ConnecticutDocumentsSpring 24CSE 2050cse2050hw1letters.py”  Process finished with exit code 0>>> counts = letter_count(‘frost.txt’)>>> print(counts){`a`: 13, `b`: 2, (24 letter:count pairs omitted)}>>> freqs = letter_frequency(counts)>>> print(freqs){‘a’: 0.06190476190476191, ‘b’: 0.009523809523809525,(24 letter:frequency pairs omitted)}import letters def highest_freq(file): ”’Given a file name, calls functions from letters.py and returns the letter with the highest frequency and its ratio”’ letter_count = letters.letter_count(file) letter_freq = letters.letter_frequency(letter_count) keymax = max(letter_freq, key=letter_freq.get) return keymax, letter_freq[keymax]ltr, freq = highest_freq(‘frost.txt’) #third test assert(ltr) == ‘e’ assert(freq) == 0.10952380952380952“C:UsersartjsOneDrive – University of ConnecticutDocumentsSpring 24CSE 2050cse2050hw1.venvScriptspython.exe” “C:UsersartjsOneDrive – University of ConnecticutDocumentsSpring 24CSE 2050cse2050hw1highest_freq.py”  Process finished with exit code 0 Broadly speaking, we’ll grade this and all assignments on four main areas:∗ input – text file∗ output – dictionary of letter:count pairs∗ input – dictionary of letter:count pairs∗ output – dictionary of letter:frequency pairs∗ input – a text file∗ output – highest frequency letter in form of a tuple: (letter, frequency)   Print statements are not valid tests – use assert instead.     Every function you write in this course should include a docstring.

$25.00 View

[SOLVED] Cmpsci 403: introduction to robotics: perception, mechanics, dynamics, and control hw 08

1 Discrete Impact Based Contact Simulation ✓1 ✓2 m1,I1 m2,I2 (0, 0) ˆj ˆi B C Figure 1: Double pendulum model. In this problem, you will extend your previous simulation to include constraints. In this homework, we will add the slippery surface, which makes a friction force depending on the friction coefficient and the normal force. Please include your simulate_pend_HW8.m code in your submission. 1. Given a ground height yc = −1.1 m, complete skeleton the code for the function discrete_impact_contact in simulate_pend_HW8.m. This function should: • Compute the height of the foot relative to the ground Cy = y − yc. • Compute the C˙ y = ˙y. • If the constraints are not violated (i.e. Cy > 0 or C˙ y > 0), then your function should not update q˙. • If the constraints are violated (i.e. Cy < 0 and C˙ y < 0), compute the vertical impulse force, Fˆ c,y = Λc,y(−γC˙ y − Jc,yq˙), where Λc,y is the vertical directional operational space mass, γ is the coefficient of restitution, and Jc,y is the vertical directional Jacobian at the contact point. • Update q˙ using the equation, q˙ = ˙q + M−1J > c,yFˆ c,y. • Using the same procedure, update q˙ by applying tragential impulse force to satisfy a friction cone constraint. Compute the tangential impulse force, Fˆ c,x = Λc,x(0 − Jc,xq˙). • Truncate Fˆ c,x if it is outside of friction cone, > µFˆ c,y. • Update q˙ using the equation, q˙ = ˙q + M−1J > c,xFˆ c,x. 2. Find a proper place to put the update function in the simulation. Does it need to be in dynamics function? Or in the middle of numeric integration? 3. Use the coefficient of resitution γ = 0 and a friction coefficient µ = 0.3 to simulate trajectory tracking for the circle task with ω = 3 rad/s. Provide position and velocity plots of x and y over the interval t = [0s, 10s]. 4. Increase µ to 3 and perform another simulation. Describe what changes in this simulation. 1 5. (Optional) Note that this method for enforcing constraints is general to cases beyond contact with the ground. For instance, in reality, this mechanism has a kinematic joint limit that constrains q1. In your code, implement a joint limit constraint to enforce q1 > −0.1 rad. 2

$25.00 View

[SOLVED] Cmpsci 403: introduction to robotics: perception, mechanics, dynamics, and control hw 07

1 Operational Space Control In HW6, you made a dynamics simulation for the robot shown in Figure 1. Given a desired position of the foot r d C = [xd, yd] >, your control law took the form: τ = J TK(r d C − rC ) + D(r˙ d C − r˙ C ). (1) As we watched in the lecture, this method effectively controlled the position of the foot using a virtual spring-damper in task-space. However, the Jacobian J = ∂rC ∂q was the only part of this control law that required information about the model! This homework will explore methods to improve the performance of the controller using more information about the model. Specifically, we will use information about its dynamics. As we have seen in class, the dynamics of the leg are given by the configuration-space equations of motion: M(q)¨q + C(q, q˙) + G(q) = τ (2) After a bit of algebraic manipulation, these equations can be rearranged into the operational-space equations of motion to describe the dynamics of the end-effector: Λ(q) ¨rC + µ(q, q˙) + ρ(q) = F (3) where Λ(q) is the effective mass felt at the foot, µ(q, q˙) gives the coriolis and centripetal forces on the foot, and ρ(q) gives the gravity force felt on the foot. Formula for these quantities are given below: Λ(q) = (JM−1J T ) −1 (4) µ(q, q˙) = ΛJM−1 C − ΛJ˙ q˙ (5) ρ(q) = ΛJM−1 G (6) ✓1 ✓2 m1,I1 m2,I2 (0, 0) ˆj ˆi B C l1 l2 c1 c2 Figure 1: Double pendulum and parameter definitions. 1 In this assignment, you will explore the use of an extended version of Eq. 1 given by: τ = J >Λ¨r d C + K(r d C − rC ) + D(r˙ d C − r˙ C )  + µ + ρ. (7) Under mild assumptions, it can be show that the foot will converge to the desired trajectory with this control law. 1. Download the derive_eqns.m code. Using the simulate_pend.m code as a simulator, implement the control law in Eq. 7 in controller.m. The script derive_eqns.m creates a number of useful functions what will help in implementing the controller once you specify kinetic/potential energy and generalized forces. With your operational space controller, run the circular trajectory tracking simulation. You should use parameters: r d C (t) =  0.5 + 0.25 cos(ωt) −1 + 0.25 sin(ωt)  (8) ω = 2π rad/s (9) K =  50 0 0 50 (10) D =  5 0 0 5 (11) q|t=0 =  π/6 π/6  (12) q˙|t=0 = [0, 0]> (13) Turn in a plot of of x, y, xd, and yd versus time. 2. Repeat step 2. using modified control laws: • τ = J TΛ¨r d C + K(r d C − rC ) + D(r˙ d C − r˙ C )  + µ• τ = J TΛ¨r d C + K(r d C − rC ) + D(r˙ d C − r˙ C )  + ρ• τ = J TΛK(r d C − rC ) + D(r˙ d C − r˙ C )  + µ + ρTurn in a plot of of x, y, xd, and yd versus time for each case. Also, include a short description of what is neglected in each controller, and how that relates with the observed performance. For comparison, you probably need to try different trajectory speed, link masses, or feedback gains. 3. Turn in your controller.m and derive_eqns.m code

$25.00 View

[SOLVED] Cmpsci 403: introduction to robotics: perception, mechanics, dynamics, and control hw 06

Using the example given in class as a guide, derive the equations of motion (in Matlab) for the double pendulum with parameter definitions as in the figure below. A torque τ1 with vector τ1 ˆk (where ˆk = ˆi × ˆj) acts between the base and body 1, and a torque τ2 with vector τ2 ˆk acts between body 1 and body 2. Assume gravity g = 9.81 m/s2 in the −ˆj direction. Write a function to simulate the double pendulum. Provide a copy of your working code. ✓1 ✓2 m1,I1 m2,I2 (0, 0) ˆj ˆi B C l1 l2 c1 c2 Figure 1: Double pendulum and parameter definitions. 1. With τ1 = τ2 = 0, solve the initial boundary value problem from the initial condition θ1 = 3 rad, θ2 = 0 rad, ˙θ1 = ˙θ2 = 0 rad/s on the time interval t = [0 s, 7 s]. Use parameters m1 = m2 = 1 kg, I1 = I2 = 0.05 kg·m2 , l1 = 1 m, l2 = 0.5 m, c1 = 0.5 m, c2 = .25 m. Plot θ1(t) and θ2(t). Does the solution display any repetitive and predictable patterns? 2. Plot the total system energy (T + V ) over the same interval. Verify energy conservation (You will see almost constant energy having a small drift). 3. (Optional) Derive the equations again considering the addition of three springs with potential energies Ve1 = 1 2 κ1(θ1 − θ1,0) 2 Ve2 = 1 2 κ2(θ2 − θ2,0) 2 Ve3 = 1 2 k3(∥rC − r0∥ − l0) 2 The vector r0 = [rx ry] T represents the attachment point for the last spring. 4. (Optional) After verifying energy conservation of your equations, simulate the system with κ1 = κ2 = 10 Nm/rad, k3 = 50 N/m θ1,0 = θ2,0 = 0, l0 = 0, rx = 0 m, ry = 0.5 m Apply τ1 = − ˙θ1 and τ2 = − ˙θ2 and use the same initial state as in step 2. 1

$25.00 View

[SOLVED] Solevd cmpsci 403: introduction to robotics: perception, mechanics, dynamics, and control hw 05

1. Make a Matlab function that computes a Jacobian matrix in global frame given joint positions. 2. Find the joint configuration that coincides with the following end-effector goal position and orientation (i.e EE SE(3)) and submit a screenshot of the robot’s posture in the kinematic simulation you built in homework 4. 0Tgoal =   0 −1 0 0.2 1 0 0 0.31 0 0 1 0.2 0 0 0 1   , Tip: Use the Jacobian you found in question 1 together with Newton-Raphson method to find the joint configuration. Figure 1: Six DOF arm in its home configuration (i.e θ1 = θ2 = θ3 = θ4 = θ5 = θ6 = 0). Notice the local frame of the end-effector {EE} is aligned with the global frame {0}. Each of the cylinders represent the joints of the robot and the arrows going through the cylinders represent the axes of rotation. Therefore, θ1 is the rotation around z axis, θ2,3,5 are the rotation around y axis, and θ4,6 are the rotation around x axis. 1

$25.00 View

[SOLVED] Cmpsci 403: introduction to robotics: perception, mechanics, dynamics, and control hw 04

1. Build the robot kinematic simulation and submit a screenshot of the robot in the following two configurations. You can use the given “drawLine3D.m” and “draw_Coordinat3D.m” functions to plot and refer to “matlab_test3D.m” for instruction. (a) q = (00 , 900 , 0 0 , 300 , 900 , 0 0 ) (b) q = (00 , 1200 , 0 0 , 600 , 900 , 0 0 ) 2. Find the corresponding end-effector (i.e EE) SE(3) for the following two configurations. (a) q = (00 , 900 , 900 , 300 , 900 , 0 0 ) (b) q = (00 , 600 , 450 , 600 , 900 , 0 0 ) Tip: Use the functions you implemented for homework 3 to construct SE(3) matrices. Figure 1: Six DOF arm in its home configuration (i.e θ1 = θ2 = θ3 = θ4 = θ5 = θ6 = 0). Notice the local frame of the end-effector {EE} is aligned with the global frame {0}. Each of the cylinders represent the joints of the robot and the arrows going through the cylinders represent the axes of rotation. Therefore, θ1 is the rotation around z axis, θ2,3,5 are the rotation around y axis, and θ4,6 are the rotation around x axis. 1

$25.00 View

[SOLVED] Cmpsci 403 hw 03: 3d open-chain robot representation

1. Make a function in Matlab to convert ZYX Euler angle to an orientation matrix, and nd the orintation matrices coincide to: ZYX = (0.3, 0.2, 0.5), (0.7, π, π 2 ), ( π 3 , 0, 0) Matrices: Code: 2. Make a function in Matlab to construct SE(3) from rotation matrix and translation vector, and make a function to multiply two SE(3)s and make a function to invert SE(3), then nd the transformation matrix of frame{3} to frame{0} T03 from the following Euler angles and translation vectors: frame{0}: Euler angle ZYX = (0, 0, 0), position: (0, 0, 0). frame{1}: Euler angle ZYX = (0.3, 0.2, 0.5), position: (0.4, 0.8, 1.2). frame{2}: Euler angle ZYX = (0.7, π, π/2), position: (-0.4, 0.5, 1.0). frame{3}: Euler angle ZYX = (π/3, 0, 0), position: (0.5, -0.8, 1.2). Matrix: Code: 3. Plot above frame{1}, frame{2}, frame{3} in global coordinate frame{0}. You can use the given “drawCoordinat3D.m” funtion to plot and refer to “matlab_test3D.m” for instruction. Figure: Code: 4. Show the animation of frame EE at frame 3. Let frame EE has the same rotation matrix as frame 3 and the translation vector is [x, y, z] where x=0.1sin(ωt)+0.05, y=0.3cos(ωt)+0.08, z=sin(ωt)+0.5. t lasts a few seconds. Refer to “animation2D.m” for instruction. Please provide several screen shots to represent the animation. Snapshots of motion: Code: 1

$25.00 View

[SOLVED] Cmpsci 403: introduction to robotics: perception, mechanics, dynamics, and control hw 02

1. How many degrees of freedom (n) does this mechanism possess? 2. Where would you attach motors to control the position of the end effector in the plane? 3. Based on your choice, define joint position vectors q ∈ R n and derive forward kinematic equations that relate the inputs (motor angles) to the outputs (end effector position in Cartesian coordinate, i.e. p = (x, y)). 4. Obtain the Jacobian matrix J(q) = dp dq symbolically in Matlab. 5. Use this Jacobian to relate output forces (Fx, Fy) at the tip of the arm to statically equivalent input torques (τ1, τ2). Assumptions and tips: • You should define fixed parameters as necessary. • You can assume that the linkage is a parallelogram. • Consider using Matlab functions: syms, eval, jacobian • You may want to read the Matlab Symbolic Computation Toolbox Tutorial before getting started: http://www.mathworks.com/help/symbolic/performing-symbolic-computations.html Ground y x (Fx , Fy) p(q) = (x, y) End effector 1

$25.00 View

[SOLVED] Cosc 450 project 3 – report on comparison of languages

COSC 450 Project3 1 Project3 – Report on comparison of languages Due by 12/8. Specifications: 1. It is an individual assignment. 2. Each student needs to gather materials for a computer programming language (but not Java, or C, or the language you used for Project 2), organize the materials in a systematic way, create appropriate report for the materials, submit your report to the Blackboard by due date. 3. Each report should include the following information if applicable (but not limited to): a. a brief history of the language; b. the data types of the language; c. flow control; d. subroutines; e. user defined types; f. program file organization; g. generics; h. concurrency; i. a summary of the main features (merits and deficiencies) of the language; j. and importantly a comparison of this language to the language you used in Project1. COSC 450 Project3 2 Presenters, Topics, and Dates: Last Name First Name Project2 Project3 Presentation Date Akinfeleye Kunle Python PHP 12/08 Barton Benjamin Ruby Julia 12/03 Champ James PHP R 12/03 Ebersole Brendan Python AWK 11/24 Fearon Dakota Ruby Pascal 12/08 Gresch Christopher Python JavaScript 12/01 Grossman Anna Jenkins Adam Python Perl 12/01 Metcalfe Hunter Python Fortran 12/03 Newcomer Eric PHP Haskell 12/08 Raoofi Seyed Haskell Ruby 11/24 Ridenour Curtis PHP VB 12/10 Robertson Luke AWK Lisp 12/10 Rohwein Jayden PHP Basic 12/01 Sanchez Claudia Shechter Barak Python Swift 12/10 Treasure Alexander Fortran Python 12/03 Tucker Christiana Python SQL 11/24 Yoder Kerwin Python Go 12/08

$25.00 View

[SOLVED] Cosc 450 project2 – programming in another language

Specifications: 1. This is an individual assignment. You will work on this assignment by yourself. 2. Please use any computer language (but not Java, C, or C++, and it is recommended that you choose a language you know nothing about it yet.) to create a program to do the following: a. Open and read from the data file, “COSC450_P2_Data.txt”, which contains some number of integer values (separated by white space character(s)) with the number of integers a multiple of 10. A sample “COSC450_P2_Data.txt” file will be given to you but your program should be able to process any “COSC450_P2_Data.txt” file with the above property. b. After read in the data file your program will process the integer values into two matrixes (stored in two dimension arrays): the first one with the dimension 5 * X and the second one X * 5, where X is some value determined by the number of integers in the input data file. c. Output the above two matrixes into an output file, “COSC450_P2_Output.txt”, created by your program. d. Calculate a product matrix (a two-dimension array of long integers) based on the first matrix multiplies the second matrix; e. Write the product matrix out to the same output file, “COSC450_P2_Output.txt”, by appending it to the end; f. Bonus points for undergraduates (10 points) and required for graduates: sort the product matrix and append it to the end of the above output file, “COSC450_P2_Output.txt”. Your sorting cannot be done by copy the values out from the matrix into a single dimension array then put it back but has to be done on the matrix directly by manipulating the subscripts correctly. Deliverables: 1. Submit your source code file(s) to the Blackboard before the due time. 2. Screen shot and paste the output in a word document, and submit it on blackboard. Grading: 1. Total 100 points, excluding the 10 bonus points for undergraduates.

$25.00 View

[SOLVED] Cosc 450/550 project 1 – programing in c

Specifications: 1. This is an individual assignment. You will work on this assignment by yourself. 2. Please use the programming language C to create a program to do the following: a. Open and read from the data file, “COSC450_P1_Data.txt”, which contains some number of integer values (separated by white space character(s)) with the number of integers a multiple of 10. A sample “COSC450_P1_Data.txt” file will be given to you but your program should be able to process any “COSC450_P1_Data.txt” file with the above property. b. After read in the data file your program will process the integer values into two matrixes (stored in two dimension arrays): the first one with the dimension 5 * X and the second one X * 5, where X is some value determined by the number of integers in the input data file. c. Output the above two matrixes (in a formatted way) into an output file, “COSC450_P1_Output.txt”, created by your program. d. Calculate a product matrix (a two-dimension array of long integers) based on the first matrix multiplies the second matrix; e. Write the product matrix out to the same output file, “COSC450_P1_Output.txt”, by appending it to the end; f. Bonus points for undergraduates (10 points) and required for graduates: sort the product matrix and append it to the end of the above output file, “COSC450_P1_Output.txt”. Your sorting cannot be done by copy the values out from the matrix into a single dimension array then put it back but has to be done on the matrix directly by manipulating the subscripts correctly. 3. Please start work on this project earlier. It will take some time for you to get familiar with C to create the program. Deliverables: 1. Submit your (zipped but not rar, if multiple files) C source code file(s) to the Blackboard before the due time. 2. Screen shot and paste the output in a word document, and submit it on blackboard. Grading: 1. Total 100 points, excluding the 10 bonus points for undergraduates.

$25.00 View

[SOLVED] ECE-242 Applied Feedback Controls Homework 6 Winter 2025

ECE-242 Applied Feedback Controls Homework 6 Background Initially, this is the point in the class where I would send you into the lab to learn how to control a real mechanical experiment (inverted pendulum, three disk set, caged fan, etc.).  The problem here is that the hardware has gotten so good, that essentially these now all boil down to playing with Simulink and MATLAB. If I put you on bad hardware, then you spend most of your time debugging the bad hardware  (something which I am sure you are all going to do later in your careers anyway). So, instead, I’ve got a simulink model for you to play with. This is a full, realistic control design exercise—it is open ended, the more you put in, the more you get out. Figure 1: Odyssey Spacecraft 0 Attitude Stabilization of a 1-D satellite Very often in satellite/space ship design, you wind up putting the big heavy things (engines, etc) on one end, and the sensitive sensors on the other end, and because you don’t have to support the weight (microgravity environment), you use a slender flexible truss to move them apart.  We model the torsion stages as three inertias connected by two torsional springs. To make matters more difficult, the thrusters that can torque the satellite are connected to the aft stage, not to the front where the sensors are. You do get a star tracker on each stage which gives you very high quality rotational attitude information on the fore and aft stages (but not in the middle). 1 Collocated Control The rotational dynamics of the entire satellite system, aft thrusters to aft angle, can be represented by the following transfer function (this is the easy one): where: Now, onto the design of the controller: a)  Design a lead controller, D1 (s), which gives a closed loop bandwidth of 2π rad/sec and a phase margin of at least 55。 b)  Sketch a root locus plot vs. the lead gain, Ko, indicate where your closed loop poles are. c)  Sketch your bode plot of the system, indicating cross-over frequency, and phase margins. d)  Go back and check your hand plots using MATLAB (and turn both in). e) Plot step and impulse responses of the closed loop system (include both the output and the control effort on both plots. That is plot u and θ). f)  Download the simulink model DiscoveryAft.mdl from the CANVAS website, and implement your con- troller (simply replace the D1 (s) block with your own transfer function). When you simulate the system, the variables ucon1, tcon1, and ycon1 (input, time, and output) will be populated in your workspace as arrays. Simulate your controller on the plant and verify that it matches the step response you found in part (5). g)  Convert your compensator, D1 (s), to its discrete equivalent, D1 (z), using a Tustin transformation and a sample rate of 25Hz. h)  Download the simulink model DisoveryAftDiscrete.mdl from the CANVAS website, and implement your digital controller (simply replace D1 (z) with your own transfer function).  Compare your time histories for D1 (s) and D1 (z) to see how much it hurt to go digital. 2 Non-Collocated Control When you did the control above, the output sensor and the actuator were in the same place.  This is called collocated control. You should have observed that the high frequency poles tended to have zeros close by that caused the poles to move in favorable (stabilizing) directions when you cranked up the gain. This is typically the case for collocated control. What happens when the sensor and the actuator are not in the same place? This is non-collocated control, and it gets harder. The rotational dynamics of the entire satellite system, aft thrusters to fore angle, can be represented by the following transfer function (this is the hard one): where: Now, onto the design of the new controller: a)  Design a simple lead controller, D2 (s), for the new plant, Gfore (s). How high a bandwidth can you get with this kind of compensator?  Remember that there is some uncertainty in both the frequency and damping of the poles. Use DiscoveryFore.mdl to simulate the system. b)  Convert your compensator, D2 (s) to its discrete equivalent, D2 (z), using the Tustin transformation, again with a 25Hz sample rate. Simulate it using DiscoveryForeDiscrete.mdl. Review Take the time to play with this system, and see what you can get it to do. You are free to design more complex controllers, and get a feel for controlling a more difficult system.

$25.00 View

[SOLVED] Lab 16 Collections

Java Lab 16: Collections This lab uses Collections. Create a project named Lab16. Problem statement: The application will let users display a list of movies in several orderings and search for specific movies by several criteria. The tab-delimited file "movies.tsv" has information about movies, one per line. The data's format is id#movie nameyearcountriesgenre1genre2 … where the genre list is some number of tab-delimited strings. You'll probably want to strip the strings of spaces; some of the movie names and countries are surrounded by quotes, which should be replaced with ""; there may be multiple countries listed for a movie, but treat it as one string – we won't be looking for specific countries; and finally, for some movies, the table display's formats may not be large enough, but you can ignore that – just use the given formats. Your program will present these choices in a menu: sort by ID, sort by name, sort by year, sort by year (reverse), search by name, search by year, search by genre, quit. The sort options will use the method sortBy(String), where the parameter is either "ID", "Name", "Year", or "Reverse Year", where the last one sorts from largest (most recent year) to smallest. The search options will use methods searchByName(String), searchByYear(int), and searchByGenre(String). These methods return at most 5 movies. The first returns a Movie objects that match exactly on name, the second matches on year, and the third matches on genre. Each returns an ArrayList; use displayMovies() to display the results. For consistency, call sortBy("ID") before searching – otherwise, your results may differ. To do the sorting, you need three things. First, Movie implements the interface Comparable; you'll need to implement its compareTo() method to compare movies on movieID.  Second, use an anonymous inner class (recall that this is similar to an EventHandler in JavaFX) that implements Comparator; you'll need to implement its compare() method to compare movies on movieName. Third, create a class named SortByYear that also implements Comparator; you'll again need to implement its compare() method, but this time, compare movies on the year field. You should try out (not required) Eclipse's wizard: select New->Class, name it, then in the Interface box, click Add, then find Comparator and click OK, then change T to Movie and click Finish. Here's the code for sorting by year in reverse order (from the most recent year), assuming you've written the SortByYear code: Comparator c = Collections.reverseOrder(new SortByYear()); Collections.sort(movieList, c); Screen shots (not all output shown for long results): Solution Design: Steps • Download Lab16 instructions Lab16Main.java, Movie.java, movies.tsv 1.    Complete all classes listed below. Check output with movies.tsv. 2.    Write your name and Andrew Id at the top in all Java files to be submitted 3.    Zip all the java files in a zip-file named as your Andrew ID. Submit it on Canvas. Class Member variables Methods Lab16Main • movieList: ArrayListe>

$25.00 View

[SOLVED] SEQA 100 Exercise 07 Full Script Thumbnails Web

SEQA 100 Exercise 07: Full Script. Thumbnails Concept In the profession, the expectations is that you may be creating visual stories from supplied scripts.  This would include drawing characters that aren’t your own, or working from a script. that you did not write. In this project students will experience working from a full mainstream professional script to develop visual interpretation in the form. of thumbnails. INSTRUCTIONS Students will create thumbnails for 6 consecutive-comic-pages. •     Download the script. Exercise 07 BatmanGK_ 15 Script SEQA100.pdf •     Read through the script. to breakdown panel layouts on the script. (for best results) •     Create digest-size thumbnails for the 6 consecutive-comic-pages out of the script. •     Thumbnails should be done in spreads: page 1, pages 2&3, pages 4&5, etc. •     Page orientation should be portrait, vertical (not landscape, horizontal) •     Digest size (5.5” x 8.5”); Download template: Thumbnail Template.pdf •     Sharpie/felt-tip; Pencil is fine, but should be dark and clear (Digital pencils, optional) •     Balloon placement should be clear •     Number each dialog per page (each page starts with balloon #1) •     Scan and darken for legibility Things to Remember: •     This project showcases your panel layout •     Thumbnails are intended to be fast, not detailed •     Don’t forget the other things learned in this class so far. •     Clarity of image and action is always important. •     Remember: give your characters something to do/explain with their hands. •     This is your interpretation of the script, there is no wrong way, you make the decissions •     DO NOT look at the original published comic. Any reference or similarity to professional designed panels and images will be an automatic failing grade for this assignment Presentation: 1.    Scan (no phone camera photos) and clean up final art and SAVE as a multiple page PDF 2.    Projects should always be scanned, cleaned up 3.    Label your file: (student last name) Exercise_07_BatmanThumbnails.pdf example: Smith_ 07_BatmanThumbnails.pdf 4.    Post to Discussion Board for review in class 5.    Submit to SUBMISSIONS for grading DUE: Class 16 (Review)* DUE: Class 17 (Present)* Discussion Board If you are not attending class, you must articulate your presentation in writing on the discussion board (see grading criteria below). Deadline Policy: It is class policy that No Late Assignments will be accepted. A project submitted by the deadline to Discussion Board for in-class review, but not submitted electronically to SUBMISSIONS, will not be graded. Incomplete work can be submitted for partial grade if submitted by the deadline. *NOTE: Completing less than 60% of the pages is an automatic failure Grading Criteria: Category Excellent (A) Good (B) Average (C) Poor (D) Fail (F) Review Presentation, Analysis and Articulation The student demonstrates an excellent presentation, insightful analysis  and articulation    when presenting  pages for review. The student demonstrates a good presentation, with  elements insightful analysis and articulation when presenting pages for review. The student demonstrates an average presentation, with little insightful analysis and articulation when presenting pages for review. The student demonstrates a poor presentation, with little or no insightful analysis  and articulation    when presenting  pages for review. Did not complete by deadline; and/or did not post with written articulation. Narrative Clarity The student did an excellent job in creating acting of characters and scenes that communicate story. The student did a good job in creating acting of characters and scenes that mostly communicate story. The student did an average job in creating some acting of characters and scenes that somewhat communicate story. The student did a  poor job with very little acting of characters and scenes that do not always contribute   to story. Did not complete by deadline/ or completed less than 59% / or does not meet the criteria stated in the assignment sheet Page Action Flow The student did an excellent job in designing panel      information that      contributes to flow of action. The student did a good job in designing panel     information that     mostly contributes to flow of action. The student did an average job in designing panel information that somewhat contributes to flow of action. The student did a poor job in designing panel   information that   rarely contributes to flow of action. Did not complete by deadline/ or completed less than 59% / or does not meet the criteria stated in the assignment sheet Word Balloons The student did an excellent job in communicating     flow of dialog through balloon placement as specified in the script. The student did a   good job in mostly communicating     flow of dialog through balloon placement as specified in the script. The student did an average job in somewhat communicating flow of dialog     through balloon placement as specified in the script. The student did a poor job in rarely  communicating   flow of dialog through balloon placement as specified in the script. Did not complete by deadline/ or completed less than 59% / or does not meet the criteria stated in the assignment sheet Craftsmanship The student did an excellent job in mark making of that are clear and neat. The student did a good job in mark making of that are mostly clear and neat. The student did an average job in mark making of that are somewhat clear and neat. The student did a   poor job in mark     making of that are not very clear and neat. Did not complete by deadline/ or completed less than 59% / or does not meet the criteria stated in the assignment sheet Presentation, Analysis and Articulation The student demonstrates an excellent presentation, insightful analysis  and articulation   when presenting. The student demonstrates a good presentation, with  elements insightful analysis and articulation when presenting. The student demonstrates an average presentation, with little insightful analysis and articulation when presenting. The student demonstrates a poor presentation, with little or no insightful analysis  and articulation   when presenting. Did not complete by deadline; and/or did not post with written articulation. Grading Weight: Review                                                                               20% Narrative Clarity                                                              20% Page Action Flow                                                           20% Word Balloons                                                                  10% Craftsmanship (neatness)                                    10% Presentation                                                               20% Total                                                                             100%

$25.00 View

[SOLVED] EIE2105 Digital and Computer Systems Tutorial 1 Number Systems Operations and Codes

Department of Electrical and Electronic Engineering EIE2105 Digital and Computer Systems Tutorial 1: Number Systems, Operations and Codes 1.     Convert the following decimal values into binary. a.)    20.7510                                             b.)   25.62510 2.     Convert the following binary values into decimal. a.)    1011.0112                                      b.)    11010.112 3.     Convert the following binary values into hexadecimal. a.)    1101.1012                                       b.)    101.11012 4.     Convert the following hexadecimal values into decimal. a.)   AB.C16                                             b.)   45.516 5.     Calculate the following arithmetic operations (show all steps in details). The numbers are 8- bit unsigned integers. a.)    01110000 × 00000011 b.)   01111000 + 00001111 c.)    01111000 - 00000011 6.     Derive the truth tables of the following Boolean functions, rewrite them in Sum of Minterms and Product of Maxterms, and write down their formal shorthand. a.) F(A, B, C) = AB + AC b.) F(A, B, C, D) = AB + AC + BCD + AD 7.     Optimize the following Boolean functions F by K-Map. a.) F = abcd + abcd + abcd + abcd with don’t care terms: a bcd , a bcd , a bcd , a bcd , a bcd , a bcd b.) F = a bcd + a bcd + a bcd with don’t care terms: a bcd , a bcd , a bcd , a bcd , a bcd , a bcd c.) F = a bcd + a bcd + a bcd with don’t care terms: a b c d , a b cd , a bcd , a bcd , a bc d , a bc d

$25.00 View

[SOLVED] N1592 Trading Strategies Midterm Assessment Outline

N1592 Trading Strategies Midterm Assessment Outline For the purpose of completing this assessment you need to utilise Bloomberg Terminal. Choose 2 out of 4 below tasks for your report. Please note you need to select only 2 out of 4 tasks and competing 2 tasks in the lab should not take you more than an hour. After completion of the tasks export your results in a PDF format and cut and crop relevant graphs and tables into your report. TASK 1 Test the Value Strategy utilising relevant Bloomberg functions, including backtesting, for the following time periods – 20/01/2017 to 20/01/2021 and 20/01/2021 to 20/01/2025 using US & UK, and ONE of the following - Chinese (Shanghai Shenzen 300 Index) or Japanese (Nikkei 225), or Scandinavian (OMX Nordic 40) market data. Identify the most relevant filters and explain why they are the most relevant to testing of this strategy. After forming portfolios using filters and generating results, comment on the differences in returns across these two time periods. Analyze whether the Value Strategy performed empirically better during the first Trump presidency or the Biden presidency. TASK 2 Choose a stock and using appropriate Bloomberg functions identify whether this stock is consistent with the Fisher’s Growth Strategy and using Bloomberg terminal identify a suitable comparable stock. Explain why you chose those specific Bloomberg functions and how you utilized data derived through these functions to complete your analysis. TASK 3 Test Dreman’s Contrarian strategy by looking at performance of domestic companies closely around the Brexit Referendum result (make sure the backtesting includes this period). Answer the following questions: A) Which industry leads the crisis? B) Which industry in the portfolio contributes the most to the downturn? C) Comment whether the findings derived provide empirical evidence of the Contrarian approach? TASK 4 Apply the relevant steps in the Bloomberg Terminal to test whether Portfolio Diversification theory holds empirically in the U.S. market over the past 10 years (25/02/2015–25/02/2025). Comment on the relevant characteristics and influencing factors.

$25.00 View

[SOLVED] NE/PS212 - Introduction to Programming for Research in Psychological Brain Sciences

NE/PS 212: Projects 1 & 2 Introduction to MATLAB Programming for Research in Psychological & Brain Sciences Please pick two of these 10 options as your first and second project.  I have tried to make them as interesting and varied as possible.  The projects are meant for you to explore and analyze the data that is provided and have fun doing it.  The class is heterogeneous and so some of you might enjoy doing one project or the other. You obviously cannot do the same project twice. Again this can be done in groups (max 2 per project!) . Ultimately, my hope is that these projects will serve as a scafold for you when you do data analysis in the real world.  The  projects are due on the  Friday the 7th of March and on  Friday the 25th of April.  Show each other your projects and help each other!  This is meant to translate your learning in the class to actual projects that one can do and gain real-world skills. Generate one or more matlab scripts or functions to answer these questions.  Ideally you  use cells to answer diferent parts of your code. You can also learn about MATLAB live scripts which allow you to present a notebook of what you did. Instructions for submission 1.  Everyone  should  submit  a  zipfile   named  lastname   project1  -  for  example   I  would  submit   “Chan- drasekaran   Project1.zip” . 2.  Inside this zip file should be: • Your main script, which should just be your last name, like ”Chand.m”, • Separate .m files for all your functions, and the data that your project uses, • A published .html or .pdf of your matlab script. 3.  To Html or pdf publish go to the publish menu → select the down arrow under publish → edit publishing options → change the  location to the  lastname   project1 folder.   (if publishing an  html  make sure all images are included, pdf is simpler) . 4.  Once all your files are in the folder, zip the folder and upload it via the link on blackboard, If you don’t know how to zip a folder: http://rasmussen.libanswers.com/faq/32413 5.  Please make sure you include your code or comments who you did the project with. 1    Psychometric and Chronometric Curves Often times in neuroscience, you need to plot the behavior of animals when they perform various tasks. In a .mat file I have provided a matrix with three columns.  The first column lists the stimulus condition which is the number of red squares in the checkerboard out of 225.   The second column lists whether the animal responded red (denoted by a 2) or green (denoted by a 1), and finally the last column the reaction time of the animal. The data are basically of a monkey performing a red-green reaction time visual discrimination decision-making task with arm movements as the behavioral report.  The psychometric curve and chronometric curve (reaction times) can be found in Figure 1 of this paper ( https://www.nature.com/ articles/s41467-017-00715-0.). We are basically replicating some of these figures with help of the data here. The data are stored in Project1   MonkeyBehavior.mat. 1. Calculate a signed coherence parameter which is given as 100*(R-G)/(R+G), print the minimum and maximum of this signed coherence parameter. (5 + 5 points). 2. Calculate the percentage of trials the animal responded red as a function of the signed coherence of the checkerboard. Plot this in a graph where the x-axis is signed coherence, y-axes is percentage responded red. T (20 points) 3. Calculate the mean reaction time for each value of signed coherence.  Plot this again in a graph where the x-axis is signed coherence and y-axes is reaction time. (20 points) 4. Can you include error bars for the reaction time curve. To calculate error bars, you first need to measure the SEM, which is defined as follows (10 points) Where X is the variable of interest (in our case RT) and N is the number of data points. Once you have an SEM. You can use the errorbar function to plot the errorbars for the data. 5. Plot a histogram of all the reaction times observed for the animal.  Does the reaction time distribution look Gaussian? (10 + 5 points) 6. Plot the median and the mean of RTs as a function of the signed coherence. Is the mean or the median larger? If so why? (10 + 5 points) 7. Label all axes and include legends and make sure all labels are legible.  Provide a title for all the graphs at the top of the figure. (This will need some research). (5 points). 8. All functions need to be commented and code needs appropriate comments.  Files should execute with minimal modification. (5 points). 9. Note we are not looking for inefficient and awful looking where people do not use for loops and manually calculate the percent red or RT for each signed coherence.  These kinds of solutions will be docked multiple points.  That is not the intent of programming in this class.  We expect clean and clearly documented code. Figure 1: What I typically expect the output from project 1 2    Properties of Distributions A  lot of analyses  in  neuroscience  and  psychology often  involve  analysis of properties of distributions.   For instance in classical signal detection theory, the assumption is that stimuli and noise are distributed according to the normal distribution.  Similarly, firing rates of some neurons can be poisson in nature.  When  neurons are poisson, the inter spike intervals are exponential.  In contrast, some neurons are more regular than poisson in which case the inter spike interval distributions follows a gamma distribution.  Reaction times often do not follow a gaussian distribution and often follow a gamma distribution.  Finally, beta distributions are often used to model undergraduate scores in exams and also as the prior in Bayesian statistics.  These are not a part of the class but will be a scafold for the future. To help you get an understanding of distributions, I am giving you the opportunity to play with datasets from these distributions.  Download the dataset from  Blackboard.  You should get a matrix with 2000 rows and 6 columns.  Each column is data generated from a distribution. There are 6 diferent distributions. 1.  Plot  the  histogram  of the  six  distributions.   We  want  2  rows  and  3  columns.    Use  20  bins  for  the histograms (10 points) . 2.  Write a function that calculates the mean and variance of the distributions (20 points) .  Remember the sample mean and the variance are given as Mean: Variance 3.  Calculate the sample mean and the sample median for the distributions and produce a bar plot of the means and medians. We want both mean and median for all distributions in the same plot and for each distribution the mean and the median should be side by side.  Do you notice something about the means and the medians of the diferent distributions? Can you comment on why the medians and means have this pattern for these distribution?  (10 + 5 + 5 points) 4.  Besides  the  mean,  median,  and  the  variance,  distributions  are  also  described  by  the  skewness  and kurtosis. Skewness tells you the assymmetry of the distribution about its mean, that is whether the majority of the data is shifted to the right or left of the mean.  A normal distribution is centered on the mean. Skewness: Kurtosis is also another quantity that describes the shape of the distribution.  It provides insight into the tails of the distribution and tells you whether the distribution is heavy (meaning more extreme values) or narrow tailed (meaning fewer extreme values) .  A normal distribution has a kurtosis of 3 and is used as a reference distribution. Kurtosis 5.  Using  your  Kurtosis  and  skewness  measures  provide  an  intelligent  and  cohesive  comment  on  the  6 distributions.  Do some research on positive and negatively skewed distributions and on leptokurtic and platykurtic distributions and use that as a scafold for your answers.  (15 points) . Write a function that returns the mean, the variance, the skewness and the kurtosis for a distribution. We expect 4 return values one for each of the metrics of the distribution.  (25 points) . 6.  Label all axes and  include legends and make sure all labels are legible.  Provide a title for all the graphs at the top of the figure.  (This will need some research) .  (5 points) . 7.  All functions need to be commented and code needs appropriate comments.  Files should execute with minimal modification.  (5 points) . 3    Variance, covariance and correlation between two sets of data Often times in neuroscience, you wish to know if firing rates of two neurons are correlated with each other. This is the field of noise and signal correlations (cf.  Ruf and Cohen, 2016) .  To calculate correlations between variables you need to define something called covariance. Remember in class, we have talked about mean and variance which have the following forms. Mean: Variance In the above equation sx  is the standard deviation and square of the standard deviation is the variance.  When one needs to understand the relationship between variables, the relevant quantity is covariance, which is We will try to implement functions to calculate these quantities using MATLAB. 1.  Generate a variable X as a column vector with  100 normally or gaussian distributed random numbers with a mean of 3 and a standard deviation of 3 . Then generate 3 variables Y1, Y2 , Y3  with the following commands. What are the sizes of the vectors you generated?  (2 + 2 + 2 + 2 + 2 points) • Y1 = 3*X + 2*randn(length(X),1); • Y2 = -3*X + 2*randn(length(X),1); • Y3 = 4 + 2*randn(length(X),1); 2.  Write a function that returns the mean and the variance when given an array as an input.  (20 points) . Run the mean and variance function on the data.  Show that your  implementation  provides the same result as built in functions in MATLAB. 3.  Do you notice any similarities between the equations for variance and covariance?  (10 points) . 4.  Plot all 3 variables versus X. We are expecting 1 figure with 3 sub plots.  We want 1 row and 3 columns of plots.  Look up the subplot command.  (10 points) 5.  Calculating covariance (a)  Write a function that calculates the covariance between two variables X and Y. (5 points) (b)  Use this function to calculate the covariance between X and each of Y1, Y2 , Y3 .  (5 points) (c)  Does your estimate of covariance  matches the results from the cov function in matlab?  Can you rewrite the function so that it provides the same result as the MATLAB function?  (10 points) 6.  Now write a function that calculates the correlation between X and Y. Correlation between two variable X and Y are given by the equation. . Again examine if the results of your function match the results of what you get from  MATLAB. (20 points) 7.  Label all axes and  include legends and make sure all labels are legible.  Provide a title for all the graphs at the top of the figure.  (This will need some research) (5 points) . 8.  All functions need to be commented and code needs appropriate comments.  (5 points) . 4    Mortgages Assume you are getting a mortgage with a housing price V, a downpayment % of d, a yearly interest rate r for n years from your friendly neighborhood bank. 1.  Install the datafeed toolbox and retrieve the 30 year mortgage rate in the united states and plot this rate. Which week was the rate highest?  Mark that point on the plot.  Which week was the rate lowest?  Mark that point on the plot?  Can you  identify which weeks that these highest and lowest rates correspond to?  (15 points) 2.  Given V, d, r, n.  Derive a formula for the amount of mortgage you pay each month?  You can define a variable called Principal (P) from V and d (20 points) . 3.  Implement this formula  in MATLAB and ask the user to input the values of V, d, r, and n and return the monthly payment (15 points) . 4.  Calculate how much you pay in interest and how much you pay in principal each month.  Plot the interest and principal for each month that you pay.  At the start of the mortgage, what are you paying for the most.  How much of your mortgage have you paid of by the year n/2 .  (10 points) . 5.  How much interest are you paying through the duration of your mortgage?  (10 points) 6.  Now assume that you  received a small windfall amount  “S”  in year 3 of your mortgage and your bank allows you to pay that towards your mortgage. Assume from month 37 onwards the mortgage is reduced. What is your new monthly payment?  (20 points) . 7.  Label all axes and  include legends and make sure all labels are legible.  Provide a title for all the graphs at the top of the figure.  (This will need some research) .  (5 points) . 8.  All functions need to be commented and code needs appropriate comments.  Files should execute with minimal modification.  (5 points) . 5    Pattern Separations In this project, the goal is to perform pattern separations as we performed in the lecture. Assume that there are 3 classes of neurons.  We  have identified 2 features for 500 neurons in each class.  We are  reaching out to you to help us with further analysis of this data and classifying new neurons that we have identified the features of.  The neuron classes are given in the attached mat file. The second variable in the file are the new example neurons. 1.  Load the  neural data and plot the diferent neurons in a 2 dimensional space.  Use diferent colors to plot the diferent classes (say red, green, blue) and diferent markers (x,o, and diamonds) (10 points) . 2.  Plot the mean feature of the three diferent neuron classes (5 points) . 3.  What  is the shape of the  clusters?   Do  you  think  the  clusters  are  equally dense?   Can  you  provide quantitative support for your conclusions?  (3 + 3 + 4 points) 4.  Create a function that takes two vectors as inputs and computes the cosine similarity between them. Show how well your function performs by comparing with simple vectors.  (20 points) . 5.  Calculate cosine similarities between the neurons in each class and mean of the features for each class. (15 points) . 6.  Calculate  mean cosine similarities  between the  neurons  in class  1 and the  mean for classes 2 and 3 . Repeat for the other two possible combinations.  Store all your answers in a 3 x 3 matrix.  The diagonal values tell you the average self similarity whereas the other  points tell you the similarity  between the neurons in class i with the neurons in class j (10 points) . 7.  Do  you  think  the  neuron  classes  are  well  separated?   Discuss  using  the  similarities  calculated.    (10 points) . 8.  Calculate the similarities for each of the new example neurons and identify which class is the most likely for each of them.  You can  use the  mean  point for the classes for calculating the similarities.   (5+5 points) 9.  Label all axes and  include legends and make sure all labels are legible.  Provide a title for all the graphs at the top of the figure.  (This will need some research) .  (5 points) . 10.  All functions need to be commented and code needs appropriate comments.  Files should execute with minimal modification.  (5 points) . 6    Simulating  the  Lorenz  Attractor  model  using  diferential  equations  (ad-vanced) This project is designed for those with prior programming experience in MATLAB and/or other languages and any experience in solving diferential equations.  This  project will provide you with the opportunity to model the chaos and uncertainty that manifests in all aspects of life, including neural networks.  Also known as the Lorenz butterly, the Lorenz Attractor is a famous system of diferential equations to determine an object’s path for any given starting position on the attractor.  There is nothing random about this system!  However, for some values of the initial parameters , r, and b, the attractor makes it so that two initial positions that are arbitrarily close (but not the same) will diverge after a number of steps.  This  is known as deterministic chaos, and relects the unpredictability that can arise from approximations and forecasting. If you want to explore the Lorenz Attractor in more detail, please refer to this great interactive model which should help give you a better initial understanding of this network: http://www.malinc.se/m/Lorenz.php The system of diferential equations for the attractor is as follows: After you have familiarized yourself with the attractor, you will need to declare your initial parameter values ( sigma , R , and, beta) and conditions (x, y, and z) .  Start your model by creating a vector with the classic attractor values. . . ...And another vector with your initial conditions.  You may begin by using x = 0; y = 1; z = 20 After declaring these values, you will also need to create a timestep variable and a timespan array.  Aim for  50,000 timesteps. 1.  Write a function ‘lorenzattractor’ that  utilizes your  initial  parameters to create the  lorenz system of three diferential equations from your parameters and initial conditions.(10 points) 2.  Now  that  you  have  your  diferential  equations,  use  the  ‘ode45’  function  (this  may  require  a  bit  of research) to solve your system.  Ode45 will  integrate the  Lorenz equations you have created over the timespan you declared, starting at your initial conditions.  Be sure to control for error tolerance using ‘options’.(30 points) 3.  Plot your attractor  in 3D! Does your graph match your expectations?  How  might it be diferent from other simulations of the Lorenz Attractor?  (30 points) 4.  Label all axes and  include legends and make sure all labels are legible.  Provide a title for the graph at the top of the figure.(5 points) 5.  Adjust your  initial  attractor values  and  re-compile.   Do  you  observe  any  changes?   How  might  they relect the idea of deterministic chaos and how it relates to our ability to create accurate predictions in neuroscience?(20 points) 6.  All functions need to be commented and code needs appropriate comments.  Files should execute with minimal modification.(5 points) 7    Analysis of spectrograms of sounds This project is suitable for students with a signal processing background or who find the class trivial right now :)! As a psychological researcher, you often spend time designing auditory stimuli for experiments or analyzing the vocalizations of species such as mice, monkeys, or lies.  One of the most handy things to do is to learn to generate sounds and play them and also analyze their structure.  Here, we will  learn how to generate simple sinusoids, amplitude modulated signals, and frequency modulated signals. For generation of sounds assume a sampling frequency of 12 KHz. Waveform amplitudes should be between -1 and +1 . Otherwise you clip sounds. Assume a length of 2 seconds. 1.  Generate an amplitude  modulated sine wave with carrier frequency  (fc) of 250  Hz and a  modulating frequency (fm) of 1 Hz and scale it by 0.8 .  (5 points) y1 (t) = 0 .8 sin(2πfmt) sin(2πfct)                                                     (11) 2.  Generate another amplitude modulated sine wave with carrier frequency (fc) of 500 Hz and a modulating frequency (fm) of 5 Hz and scale it by 0.3 .  (5 points) y2 (t) = 0 .3 sin(2πfmt) sin(2πfct)                                                     (12) 3.  Generate a frequency modulated signal with a carrier frequency (fc) of 800  Hz and a modulating fre- quency (fm) of 5 Hz and amplitude for the frequency modulation of 200 .  (10 points) y3 (t) = 0 .3 sin(2πfct + 200 sin(2πfmt))                                                (13) 4.  Generate  a  rising chirp signal with a carrier frequency  (fc) of 400  Hz and the following equation  (5 points) 6.  Concatenate all these five signals into a large variable y with a brief 0.25s silent period between them and use the audiowrite command to save to disk.  (10 points) 7.  Calculate the spectrogram of this concatenated signal y which is a time frequency signal that provides you a glimpse of the frequency content of the signal along with  how the signal varies as a function of time.  For spectrogram parameters in MATLAB use 1024 as your window size, 512 as your overlap and  1024 points for your  FFT, and  12000 as your  Fs.   (20 points) .   MATLAB has a function called spectrogram for this very purpose :)! 8.  Comment on the spectrogram of the signal and link it back to the equations you used for generating the signal.  Can you explain why you see what you see in the spectrogram?  (10 points) 9.  Download the  Project6 audioFile.mp3 file from blackboard and use the spectrogram command on it. Use 2048 samples as your window, 1024 samples as overlap, 8192 points for your FFT, and use the Fs retrieved from the file.  (20 points) . 10.  Label all axes and  include legends and make sure all labels are legible.  Provide a title for all the graphs at the top of the figure.  (This will need some research) .  (5 points) . 11.  All functions need to be commented and code needs appropriate comments.  Files should execute with minimal modification.  (5 points) . 8    Simulating  Hodgkin Huxley models of the squid giant axon (advanced) This  project  is  meant  for  people  with  significant  amount of  programming  experience  in  MATLAB  and/or other  languages  and  any  experience  in  solving  diferential  equations  using  MATLAB.  In  this  project,  you get the exciting opportunity to simulate the famous  Hodgkin  Huxley  models  of a single giant squid axon. This was one of the earliest demonstrations of the  power of using quantitative  methods to analyze single neuron spikes.  The governing equations for the  Hodgkin  Huxley  Model are as follows.  If you want to read more about Hodgkin Huxley models, an excellent introduction is available at http://www.math.pitt.edu/ bdoiron/assets/ermentrout-and-terman-ch-1.pdf.  Iam assuming the resting potential is at 0 mV like the Hodgkin Huxley experiments. The constants are as follows: For the rate constants that depend on membrane voltage assume the following equations 1.  Plot the  properties of the gating variables m,n, and h as a function of input voltage.  Does this  match your understanding of how an action potential is generated?  (30 points) . 2.  Simulate an action potential using the hodgkin huxley model.  Get it to generate a spike!(30 points) . 3.  Simulate action potentials using the hodgkin huxley model you programmed and also use several diferent currents from 2 μA to 10 μA. (30 points) . 4.  Label all axes and  include legends and make sure all labels are legible.  Provide a title for all the graphs at the top of the figure.  (This will need some research) .  (5 points) . 5.  All functions need to be commented and code needs appropriate comments.  Files should execute with minimal modification.  (5 points) . Classification and summarizing variance is a key part of neuroscience.  This project is for people who enjoy playing with high dimensional data and want to derive intuitions for principal components analysis.  I recognize for many of the class that this might not be what has been thought in lecture but there is an opportunity for you to think about these problems if you are interested in data sciences and machine learning in general. 9    Temperature data In this project, we are going to use boxplots, t-tests, anovas, and regression to understand statistical data. These statistical techniques are used often in neuroscience and psychology.  The temperature data  is just a convenient way to actually play with these techniques.  Download the  NOAA climate data from blackboard for 6 cities:  Miami, Boston, NY, San Francisco, Austin, and Bozeman.  Perform the following analysis. 1.  Use a  boxplot to plot the mean temperature over the last century (averaged over the 12 months in a year) for the cities.  Make sure you label the x-axes with the correct labels and they-axis with temperature (10 points) . 2.  Write a function that performs an unpaired t-test with pooled variance.  Is the mean temperature (Again averaged over 12 months) for NY over the last century diferent from that of Boston.  Compare your results from the outputs from the inbuilt ttest2 function which performs unpaired t-tests (15 points) . 3.  Use an ANOVA to compare the  mean temperature for the cities.  Test for the  main efect that there are diferences between the cities (15 points) . 4.  Use the multcompare function to perform posthoc tests to show that there are diferences between the cities (10 points) . 5.  Plot the mean temperature as a function of year for the six cities (10 points) . 6.  Use a regression analysis to estimate the change in temperature as a function of time.  Using the slopes can you say which city has demonstrated the most rapid change in temperature most during this last 100 years?  (20 points) . 7.  Create a plot with the slopes and confidence intervals for the slopes.  Create another  plot that shows the amount of variance explained by the regression.  Identify the two cities with the strongest efect of time on temperature. 8.  Label all axes and  include legends and make sure all labels are legible.  Provide a title for all the graphs at the top of the figure.  (This will need some research) .  (5 points) . 9.  All functions need to be commented and code needs appropriate comments.  Files should execute with minimal modification.  (5 points) . 10.  BONUS  question:  For question 2, ensure your function  has the option to  perform a t-test assuming unequal variance for the two groups. This is called Welch’s t-test.  (20 points) .

$25.00 View