Re: [Tutor] Statistics with python
Hi, I think this makes more sense to me to get the std. I will go with this route since there is a number of age groups and not just 56. Thanks guys for all your help. >>> import numpy >>> ages = [35, 45, 55, 70] >>> numpy.mean(ages) 51.25 >>> numpy.std(ages) 12.93010054098575 On Sun, Oct 14, 2018 at 1:20 PM Oscar Benjamin wrote: > I'm replying back to the tutor list. Can you reply there rather than > directly to me please? > > Also I've moved your response below mine as that is the preferred > style on this list. My answer is below. > > On Sun, 14 Oct 2018 at 16:05, Mariam Haji wrote: > > > > On Sat, Oct 13, 2018 at 10:24 PM Oscar Benjamin < > oscar.j.benja...@gmail.com> wrote: > >> > >> On Sat, 13 Oct 2018 at 11:23, Mariam Haji > wrote: > >> > > >> > Hi guys, > >> > >> Hi Mariam > >> > >> > the question is as: > >> > If a sample of 50 patients is taken from a dataset what is the > probability > >> > that we will get a patient above the age of 56? > >> > >> I can think of several ways of interpreting this: > >> > >> (a): You have a dataset consisting of 50 patients. You want to know > >> the probability that a patient chosen from that sample will be above > >> the age of 56. > >> > >> (b): You have a dataset consisting of 50 patients. You consider it to > >> be representative of a larger population of people. You would like to > >> use your dataset to estimate the probability that a patient chosen > >> from the larger population will be above the age of 56. > >> > >> (c): You have a larger dataset consisting of more than 50 patients. > >> You want to know that probability that a sample of 50 patients chosen > >> from the larger dataset will contain at least (or exactly?) one person > >> above the age of 56. > >> > >> (d): You have a larger dataset, but you will only analyse a sample of > >> 50 patients from it. You want to use statistics on that sample to > >> estimate the probability that a patient chosen from the larger dataset > >> will be above the age of 56. > >> > >> I can list more interpretations but I think it would be better to wait > >> for you to clarify. > > > > My dataset consists of 300+ patients and I want to analyze analyse a > sample of 50 patients from it. > > Yto know the probability that a patient chosen from the larger dataset > > will be above the age of 56. > > Is this a homework problem or an actual problem? > > If I had 300+ patients I would think that the best way to work out the > probability that a patient chosen from those 300+ was over the age of > 56 would be to count how many are over the age of 56. Likewise if I > wanted to estimate how many would be over the age of 56 using a > smaller sample of 50 patients then I would also just count how many > are over the age of 56 in that smaller sample. > > I'm going to guess that this is a homework problem and that you have > been asked to assume that the ages are normally distributed (which > they would not be in reality). > > Your calculation for the standard deviation given in your earlier > email doesn't make any sense. You should calculate this using a > function that calculates the standard deviation. There is one in the > numpy module: > > >>> import numpy > >>> ages = [35, 45, 55, 70] > >>> numpy.mean(ages) > 51.25 > >>> numpy.std(ages) > 12.93010054098575 > > -- > Oscar > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- *Regards,* *Mariam.* ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Statistics with python
Hi guys, I have a statistics question where I am to calculate the probability of a sample dataset. I have done the coding bit but I am not sure if I did the right thing, I just need confirmation before I submit it. the question is as: If a sample of 50 patients is taken from a dataset what is the probability that we will get a patient above the age of 56? So I know my sample mean is 50 and my no is 56 to get std I manually did 50/√56 (that's 50/square root of 56) I got the answer as 6.66 So my mean is 50 and std is 6.66 Then I did the below to get the z score and probability using scipy.stats as st m=50 s=6.66 z1 = (56-m)/s p1 = st.norm.sf(z1) print ('Probability of patient above the age of 56 is:', (p1)) Probability of patient above the age of 56 is: 0.183820506093897 Am i missing something or did I do it right? Thanks in Advance. -- *Regards,* *Mariam.* ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] python game error
Hi guys, I am still on the learn python the hard way. I built the below on python 2.7 and my OS is windows 7. I am getting this error: Traceback (most recent call last): File "ex43.py", line 205, in a_game.play() File "ex43.py", line 21, in play next_scene_name = current_scene.enter() AttributeError: 'NoneType' object has no attribute 'enter' Main code is as, an I have highlighted line 21 and 205 in green below. from sys import exit from random import randint class Scene(object): def enter(self): print "This scene is not yet configured. Subclass it and implement enter()." exit(1) class Engine(object): def __init__(self, scene_map): self.scene_map = scene_map def play(self): current_scene = self.scene_map.opening_scene() while True: print "\n" next_scene_name = current_scene.enter() current_scene = self.scene_map.next_scene(next_scene_name) class Death(Scene): quips = [ "You died. You Kinda suck at this.", "Your mum would be proud if she were smarter.", "Such a looser.", "I have a small puppy that's better at this." ] def enter(self): print Death.quips[randint(0, len(self.quips)-1)] exit(1) class CentralCorridor(Scene): def enter(self): print "The Gothons of Planet Percal #25 have invaded your ship and destroyed" print "Your entire crew, you are the only surviving memeber and your last" print "Mission is to get the neutron destruct a bomb from the weapons Armory" print "Put it in the bridge and blow the ship up after getting into an " print "escape pod" print "\n" print "You're running down the central corridor to the Weapons Armory when" print "a Gothon jumps out, red scaly skin, dark grimy teeth, and evil clow costume" print "flowing around his hate filled body. He's blocking the door to the" print "Armoury and about to pull a weapon to blast you." print "Do you shoot!, dodge!, or tell a joke? enter below." action = raw_input("> ") if action == "shoot!": print "Quick on the draw you yank out your blaster and fire it at the Gothon." print "His clown costume is flowing and moving around his body, which throws" print "off your aim. Your laser hits his costume but misses him entirely. This" print "completely ruins his brand new costume his mother bought him, which" print "makes him fly into a rage and blast ou repeatedly in the face until" print "you are dead. Then he eats you" print 'death' elif action == "dodge!": print "Like a world class boxer you dodge, weave, slip and slide right" print "as the Gothon's blaster cranks a laser past your head" print "In the middle of your artful dodge your foot slips and you" print "bang your head on the metal wall and you pass out" print "You wake up shortly after, only to die as the Gothon stomps on" print "your head and eats you" print 'death' elif action == "tell a joke": print "Lucky for you they made you learn Gothon insults in the academy" print "you tell the one Gothon joke you know" print "Lbhe zbgure vf fb sng, jura fur fvgf nebhaq gur ubhfr, fur fvgf nebhaq gur ubhfr." print "The Gothon stops, tries not to laugh, he busts out laughing and can't move." print "While he is laughing you run up and shoot him square in the head" print "putting him down, then jump through the Weapon Armory door." return 'laser_weapon_armoury' else: print "DOES NOT COMPUTE!" return 'central_corridor' class LaserWeaponArmory(Scene): def enter(self): print "You do a drive roll into the weapon Armory, crouch and scan the room" print "for more Gothons that might be hiding. It's dead quiet, too quiet" print "You stand up and run to the far side of the room and find the" print "neutron bomb in it's container. There's a keypad lock on the box" print "Wrong 10 times then the lock closes forever and you can't" print "get the bomb. The code is 3 digits" code = "%d%d%d" % (randint(1,9), randint(1,9), randint(1,9)) guess = raw_input("[keypad]> ") guesses = 0 while guess != code and guesses < 10: print "BZZZEE!" guesses += 1 guess = raw_input("[keypad]> ") if guess == code: print "The container clicks open and the seal breaks, letting gas out." print "You grab the neutron bomb and run as fast as you can to the" print "bridge where you must place it in the right spot" return 'the_bridge' else: print "The lock buzzes one last time then you hear a sickening" print "melting sound as the mechanism is fused together" print "You decide to sit there and finally the Gothons blow up the" print "ship form their ship and you die." return 'death' class TheBridge(Scene): def enter(self): print "you bust into the bridge with the neutron destruct bomb" print "under your arm and surprises 5 Gothons who are trying to" print "take control of the ship. Each of them has an even uglier" print "clown costume then the last. They haven't pulled their" print "weapons out yet, as they see the active bomb under your" print "and don't want to set it off." action = raw_input("> ") if action == "throw the bomb": print "In panic you throw the bomb at the group of Gothons" print "and make the
Re: [Tutor] Advanced python recommendations
Thank you all for the above tips. I actually did python 2 a friend sent it to me. And my current challenge with the projects bit is how to pseudo-code and which approach to use as I am not very familiar with the entire python syntax and how I can use it and as well as python algorithms. So like I get a problem to create a simple loop or remove duplicates from a list and that just doesn't process in my head and I always end up having to google, then build from there. But thank you, I guess i just have to be patient it's been 3 months since I started coding and development I am more of a front-end developer. I guess I just need to learn how to break down the problems and know what to use where. On Wed, Oct 10, 2018 at 12:44 PM Mark Lawrence wrote: > On 10/10/18 02:22, boB Stepp wrote: > > On Tue, Oct 9, 2018 at 6:54 PM Mariam Haji > wrote: > >> > >> Hi guys, I am on the last exercises of learn python the hard by Zed.A > Shaw and I am looking for recommendations on what to follow next or what > book to try next to advance my python skills to intermediate level. > > > > If you are a fan of Zed Shaw's approach, I noticed while at Barnes & > > Noble a while back that he has released a sequel to the book you > > cited, but only for the Python 3 version. You may be interested in > > that. > > > > But I imagine taking time to imagine, detail and write the code for > > projects would help you the most, as the others have said. > > > > > > After the disgraceful way that Zed Shaw wrote about Python 3 > https://learnpythonthehardway.org/book/nopython3.html I wouldn't touch > his stuff with a 100 foot long disinfected barge pole. Just a few > months after this article he came out with the Python 3 book you > reference above, presumably because he was losing cash. > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- *Regards,* *Mariam.* ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Advanced python recommendations
Hi guys, I am on the last exercises of learn python the hard by Zed.A Shaw and I am looking for recommendations on what to follow next or what book to try next to advance my python skills to intermediate level. Thank you in advance. Regards, Mariam ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor