Not sure best way to do something

Hi,
I am working on an app in which different events are executed certain precentages of the time. Right now I have my code set up so that if x is a random number between 0 and 100 then if x > 60 then 40% of the time an event will occur, if x <= 60 and x > 30 then 30% of the time another event will occur.
Is this the best way to do this? Is there a class that handles this?
Thank you for your time.

Is this the best way to do this? Is there a class that
handles this?There's no such standard class.
If you handle it correctly very much depends on how your model is constructed. Say you have two different event types. An event is selected at random and allowed to "last" for one unit of time, say 1 second, then a new event is selected randomly and so on.
Now if the probability for event 1 to be selected is 40% and the probability for event 2 is 30% then you have a third even, the no-event, which must also have a chance to be selected and consume time with a 30% probability while the other two events are at rest. If you don't consider the no-event, event 1 will happen 40/(40+30) = 57% of the time and event 2 will happen the rest of the time namely 30/(40+30) = 43%.
So to get a 40% - 30% time distribution between 2 events you also need a no-event which occupies the remaining time upp to 100%. If you leave out the no-event the time distribution will be 57% - 43%.

Similar Messages

  • I have a Mac book pro on vesion 10.6.8 and want to access icloud as it works great on my iphone 4.  Not sure best way to upgrade as some of the review of Lion on the appstore are awful.  Any advice

    I have a Mac book pro on vesion 10.6.8 and want to access icloud as it works great on my iphone 4.  Not sure best way to upgrade as some of the review of Lion on the appstore are awful.  Any advice as I also have MIcrosoft word etc and don't want to have to purchase these again.

    That is the best list ever for Lion compatibility!
    You can also do this:
    Launch the programs you know and love on your Snow Leopard Mac.
    Utilities --> Activity Monitor
    Under the "Kind" tab it will identify the programs running PowerPC, Intel and Intel 64.
    No PowerPC apps will run under Lion.
    Don't worry about Apple's system stuff like Mail, iCal, Safari.
    Don't worry about the system processes, like fontd and launchd, those will be replaced if you go to Lion.
    Just look for the programs that you need.

  • How is the best way to remove something from a photo?

    How is the best way to remove something from a photo?

    This is difficult to answer without fully knowing what you are trying to do.
    That said, a few excellent and user friendly retouching tools include:  The Spot Heealing Brush Tool, Healing Brush Tool, Patch Tool, and the Cloning Stamp Tool.

  • Not sure which way to go for transfer.....

    First; let me say that I did search for the answer to this, but I'm not sure which way to go with a lot of the answers. I'm sorry I'm asking this question for the umpteenth time. Yes; I'm one of those that understands enough about computers to make me dangerous...
    Our computers are set up on a home network. Before I got my iPod last year, we ripped all our CDs and saved them on a completely separate external drive named "M" (for music), so all 3 computers could have access to the information on the M drive.
    I get my pod & have the office computer set up to be the 'main' iTunes location, since we purchased a USB2 hub for it. I quickly learned how to direct iTunes to 'pull' the music from the M file & understand how all that works. Life is good. I even took the time to put an album art file on the M drive & insterted everything into iTunes by 'hand'.
    Bless my hubby's heart. Completely filled with computer envy, he just purchased me a brand spanking new shiney computer. Needless to say, with all these new bells and whistles, I can now use my computer as the 'home base' for all things iPod/iTunes instead of having to go downstairs to do updates, etc.
    I looked up & printed out "How to use your iPod to move your music to a new computer" from the Apple web site, which basically says to download everything onto my iPod's harddrive & do the transfer on the new machine.
    I think what I'm trying to ask, is since all the music is located on an external drive:
    When I download iTunes to iPod harddrive, are all the tags still in place? Will all the album art be correct, so when I download it onto the new computer, everything will be identical to what's on the old computer?
    --or--
    Is there another trick I can do to have everthing the same on the new computer?
    --or--
    Am I better off just having my computer go to the M drive & upload all the music onto my new computer & reload all the album art by hand again?
    My real hesitation on this method is I have a lot of things on the M drive that I changed the tags on in iTunes, & I would really hate to go & search through everything again & redo what tags I can find wrong.
    I know that this may sound like a lot of trivial questions, but with over 6,000 tracks, I'd really like the process to go as smoothly as possible.
    And once again; I'm sorry if this seems like just another 'how do I transfer' question. As I was reading the search results, I didn't notice anything that dealt with external drives being involved & I don't know if any of that makes a differance or not in all of this.
    Thank you SO MUCH for your time!!
    Dell Inspiron E1705   Windows XP   First Time Mommy to 4gen 60gb photo
    Dell Inspiron E1705   Windows XP   First Time Mommy to 4gen 60gb photo

    Sandeep,
    I have already answered a similar question from you earlier.
    Re: Netweaver after one and half year of ABAP experience...
    Please do not create duplicate threads.
    Regards,
    Siddhesh

  • What's the best way to give a user the option of stopping a vi or rerunning it? I wrote something that works but I imagine it's not the best way to do it.

    I have a VI that runs a stepper motor then stops. I wanted the operator to have the option of rerunning the VI or stopping it completely. To do this I added a while loop around the entire VI.I have an example VI showing how I accomplished this, but I'm sure there's a more efficient approach. Any suggestions?
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    EX 1.vi ‏13 KB

    There is almost never a good reason to use the Stop Sign Abort Execution function.
    Your while loop is fine.  What you really want to do is make a state machine that has at least 2 states. 1.  Running the test.  2. Idle, waiting for the user to hit a run button again, or hitting an End program button.

  • Is using 4 white rectangles really the best way to crop something in Ai?

    I'm sure someone here has used this technique before.
    (And in InDesign as well)...
    You are drawing a new image and there is extra color or
    drawn detail that extends past the border(s)... but because Ai does not
    have a "crop" tool for the document "canvas" or the vector frames themselves, you draw four opaque white (same color as the document white) rectangles and move them onto each side of the image (up to it's border).
    Then, you fuse or flatten those four rectangles somehow.
    My questions are:
    1) If this the proper technique, is Pathfinder the right tool?
    2) If it is not the proper technique for cropping, what is? Is there a way similar to how Ps crops? It seems that the crop tool in Ai is geared towards the printing process only.

    I find that using a clipping mask for a drawing (making a mask on the top layer then masking everything) moves everything to the top layer, which is not useful for art that may get edited further later. Clipping just the objects that extend past the border, on its layer (Kurt and Ray) is something I hadn't thought of; it would preserve most of your art on the desired layers.
    I tend to use white boxes on the edges of my maps if the art doesn't extend too far beyond the borders. But clipping masks do make a neater graphic (the 0,0 of the art pops up right at the edge of the InDesign/Quark picture box, which designers appreciate). FreeHand generally remembers layers for objects once you unmask them, so I mask more in FreeHand than AI.
    On a related point - when I bring in old FreeHand art to Illustrator CS4, type on paths gets positioned badly. Usually the handles on the baseline just get shifted so one word disappears, but recently I've been finding the left and right handles are stacked right on top of each other. It's necessary (once I get the handles to APPEAR) to select the TOP of the handle to shift the pair of handles to the right, then I can grab at the BOTTOM of the pair of handles to slide the left-hand handle so the type appears and I can position it.
    The problem I run into is that certain of these steps require the white cursor, and certain steps require the black cursor, and there's no way to use the black cursor on a MASKED drawing without selecting all of it (whereas in FreeHand you can switch cursors on a subselected object in a group or mask, and edit its handles, move the type along the baseline, etc). So several times the only way to grab the offending type is to unmask the art, adjust the text, then re-mask. I may be doing something wrong, however it's quite possible it's just another Adobeism I'm going to have to work around.

  • Best way to flash something ON/OFF in premiere?

    Here is a scenario: You want a graphic element to flash on and off every second in a 2 hour long sequence, what is the fastest and most efficient way to do this in premiere CS5?
    Now in after effects this would be done fairly simply with an expression and i am tempted to do a test and dynamically link it into premiere and see what happens.
    Now the most basic method is obviously to stick it in the timeline and copy and paste until your timeline is filled. This will end up with that graphic in the timeline 3600 times.
    Now we did a project like this and had 6 sequences with it and it brought CS4 to it's knees in a crushing defeat. the project was 75MB (yes bytes!) and took 10 minutes to load and CS4 was fairly dysfunctional once it loaded. Now converting it into CS5 was better and it could at least handle it but it still was the slowest i have ever seen CS5 run, it took 2 minutes to load but it least it was somewhat editable after it loaded.  The project only had like 10 media files in it.
    Is there some faster and more effecient way to do this type of effect? apparently premiere can't really handle having that many edits in a sequence. I thought about trying to just adjust the transparency 0 to 100% but cant think of any way to replicate that easily.
    in the end we just had to render it out and delete the sequence to make it work but we want to have it in the project and be able to change things and not pre-render.
    thanks

    function(){return A.apply(null,[this].concat($A(arguments)))}
    Jay Gladwell wrote:
    Wow, a graphic element that will flash on and off every second for two hours!
    Was this devised to replace waterboarding?
    Ha!, naw, actually it's just a simple camcorder record light replication. (same difference?)

  • Best way to load something.

    Well, I'm making a game and I trying to find a way to load a list of NPCs the best... I have tried a CFG file but that raises the memory usage a lot... I was wonder if a XML file would do good.
    Anyone know that would be great.
    Thanks,
    Impulser

    Maybe I don't understand, but a file is a file, right ? No matter what content is has.
    If you want to avoid having to store a large amount of data from the file, then don't read it at once, but read it in portions.

  • What is the best way to migrate photo library to new Mac ?

    Hi .... I just bought off ebay an Mac Mini 2.53Mhz running Mountain Lion . This was a great and cost effective purchase to upgrade my very tired Mac Mini 1.6 duo running Snow Leopard (still going as a second computer) .
    However , I am not sure best way to transfer over my photos ?
    I have a Time Capsule and I can use migration assistant
    - but when doing this and choosing just photos nothing else , the process creates a new user and is a real mess on the desktop.  Thus I am left with two users on the computer : and I can't access the photos from the 2.53 Mac mini user that I created for the computer , I have to log in to this restored profile.  Annoying !
    - I believe migration assistant linking the two macs through an ethernet cabe will give the same results
    I have now purchased a firewire cable 400 to 800 , so the two macs are now linked . Would this be a cleaner way to transfer photos ? How should I set about it. I don't want to drag over any mess from the old computer ... I just want to get the photos onto the new computer and then link that to time capsule.
    Thanks

    Hey there cosmiconion,
    It sounds like you are needing to copy over a folder containing images from your Snow Leopard computer to your newer Mountain Lion machine. You can do this by enabling File Sharing for that folder or directory, then accessing that from Finder on your newer computer, and this article will help you do that:
    Mac Basics: File Sharing - Apple Support
    Thank you for using Apple Support Communities.
    Regards,
    Sterling

  • Best way to control graphics synchronized to video cue points

    Hello,
    I've recently completed (well, 'completed' is a strong word)
    a phase one implementation of a synchronized video presentation
    using After Effects and Flash. The basic idea driving the
    synchronization of cue points to motion graphics revolves around
    creating a listener in the following fashion:
    var listenerObject:Object = new Object();
    listenerObject.cuePoint = function(eventObject:Object):Void {
    // Put any code you like here
    trace(&quot;Cue point name: &quot; +
    eventObject.info.name);
    my_FLVPlybk.addEventListener(&quot;cuePoint&quot;,
    listenerObject);
    and then using the cue point name to play a variety of
    movieclips at the appropriate time in the presentation.
    The video presentation had four sections, each of which could
    be arbitratrily browsed to at any point in the presentation, so it
    was important that the the movieclips did not need to play in order
    and that they could be interrupted at any point without an visual
    confusion.
    I dealt with this two ways (I am sure these are not the best
    ways, which is why I am writing this post):
    First, every single movieclip was already on the stage from
    the outset, stopped on the first frame, with the alpha property set
    to 0 (based on Aran Balkan
    http://aralbalkan.com/444).
    The final frame of each clip had a gotoAndStop(1) action on it so
    that when a clip finished playing it 'reset' itself. I also wrote a
    &quot;rewind&quot; function which pretty much did the same
    thing whenever a user clicked on one of the navigational tabs.
    For a first iteration, this worked pretty well, and it
    impressed enough people in my organization (university) that now
    the President wants to deliver a similar message. It seemed prudent
    at this point to ask a general question about best practices in
    this area. I am working with the full Master Collection suite, and
    can target later versions of the Flash Player (I believe I can use
    AS 3.0, although I will have to learn it). One thing that I am
    hoping any pointers you guys might have will cover is this:
    How do you handle starting/stopping/pausing of the video and
    also make sure any currently playing graphical assets also
    start/stop/pause on cue? I was thinking of setting a variable on
    the second frame of each movieclip, something along the lines of
    'nowPlaying = this;' and then resetting that to null at the end of
    the clip and in the rewind function, then using that variable to
    control the currently playing clip (would have to bu just one, I
    imagine).
    But there has got to be a better way. I have some down time
    to do research and to experiment, but it is going to be very high
    profile when it rolls around, so I thought I'd send out some
    feelers.
    Has anyone done anything like this? Seen a better way? Etc .
    Thanks so much.

    Best practice is to keep one single file as long as humanly possible.
    In this case, you "branched" a version for another format; I'd suggest you don't edit that any further (apart from the formatting stuff you mentioned), but inform your client this version is to be worked on. Work on your "real" version until it's really really done, and only then make other versions.
    It's a different story (no pun intended) if the transition between the two versions can be automated; that way you'd still only work on the 'real' version, but then you could generate the other with every edit you make -- you should still not be doing any work in the dumbed-down version.

  • Step by Step, what's the best way to shoot slow-mo in HD?

    I've read so many articles on here about doing slow motion shooting in final cut but everyone of them left out some important details.
    i wanted to see if anyone could give me a step by step on how the best way to shoot something in slow motion in HD would be?
    i'm probably planning on just doing this in 720 instead of 1080, but i don't want that to begin to be the topic of discussion, just how how to do slow motion.
    some things i want to know about it:
    -what is a good shutter speed for this to make the movement look as smooth as possible
    -how many frames per second should i shoot? (my camera only goes up to 60fps)
    -should i use Cinema Tools in any way?
    -any adjustments i might need to do to the timeline in final cut when i drop it in there?
    -also, i'd want my whole project video to be done in 720/24p, but i'm guessing for the one shot i want in slow motion i'd have to shoot 720/60p. what do i need to do to get the 60fps footage to work right in a timeline set for 24fps?
    if you can't answer all of them, just some help would be greatly appreciated! Thanks!!

    -what is a good shutter speed for this to make the movement look as smooth as possible< </div>
    that's a tough call because the shutter speed will be determined by three things, your ability to understand what we tell you here, yoru photo subject, and the lighting conditions and ability to control them.
    -how many frames per second should i shoot? (my camera only goes up to 60fps)< </div>
    You can stop there, 60 is not nearly enough to achieve "smooth as possible" slow motion. You need at least 90 frames per second, 120 is even better, 180 is fabulous. You can research "overcranking," temporal resolution, and shooting slow motion for may hours on google.
    Post processing a video clip using optical flow is not a viable solution for most subjects. You must consider renting a camera that will do the job properly. If 60 fps is all you're willing or able to shoot, then you must diminish your expectations and carefully consider your photo subject.
    bogiesan

  • Best way to store and back up data on Mac (retina)?

    Ok so I bought the 13 inch retina macbook pro (This is my very first mac btw, so I am still trying to get used to basic functions though it's getting there..) and I've researched it a bit but I have some issues on figuring out how I best should store my data.
    1. Is Time Machine not the best way to back up data? As it will delete the oldest data once the hardrive used is full?
    but on the other hand, backing things up manually will take a lot of pain and effort (Choosing the new files that haven't been transferred, accidentally copying a file you actually already put in your back up disk thus taking additional unnecessary space,etc) ...right?
    or is there a better way to do this?
    2. I want to have all media (music, photos, videos, anything except apps) on an external hard drive but I don't want to have to keep transferring it from iphotos or anything else to my external hard drive...
    Is there a way to do this a smarter way? It would be best if I could put everything directly to my harddrive instead of having to import thru iphotos (thus taking up space on my internal SSD first) THEN deleting it from iphotos :/
    As of now I am trying do configure this network storage system (called SeaGate GoFlex Home if anyone is interested) but I am wondering if this is really a reliable way to keep my stuff... I plan on putting music, photos and videos on there..along with word documents
    Is there a way to configure the mac to automatically download stuff to my external network drive instead of saving it on my SSD?
    Thanks in advance for any help /opinions

    kj8P wrote:
    Is Time Machine not the best way to back up data? As it will delete the oldest data once the hardrive used is full?
    Although Time Machine does delete oldest data when full, it doesn't back everything up every time - only the files that have changed since the last backup.  Storage is cheap these days so if you get a good sized drive (seems daft to get less than 1Tb and 2 or 3Tb cost not a great deal more), then unless you have a really large SSD on your MBP and fill it with stuff, it will be a long time before Time Machine starts deleting old stuff. Aim for a minimum of double your SSD capacity.
    This article gives a very detailed explanation of Time Machine and how it works - bear in mind that even when TM has to delete the oldest backups, it will not delete something that does not have a newer version.
    http://icanhelpyourmac.com/tip_archive/understanding_apples_time_machine/index.h tml

  • Best way to include appendices to pages document

    I am trying to transition from using MS office (for over a decade now) to using the Apple suite of apps.
    I am in grad school so I write a lot of papers. I am working on one now that requires appendices at the end. I am working on the paper in sections right now (main body, appendices 1, 2, 3, etc..) and was curious what the best way to do something this is in pages?
    Can you create different sections within one one document instead of simply copying and pasting the appendices at the end of my document? That would be a big hassle, going back and forth between different files. Like I said, I would like to be able to keep them all on one document.
    Any ideas? Do you think it's perfectly doable in grad school to use only Pages for your word processing needs? (I've had to many crashes with Office on my mac, and am ready for the full change over.) Any advice, or suggestions?

    Rick
    I am not a real user of Word but I can give you some of the obvious things that Word has that Pages does not.
    1. More layouts: Draft/Web/Outline/Print/Notebook/Publishing
    2. A real desktop in Publishing that you can move objects to and off that surrounds the page
    3. Themes which set basic fonts and color schemes
    4. Non-printing characters
    5. Much bigger collection of Objects/Shapes
    6. Sophisticated diagramming tools (SmartArt)
    7. ClipArt
    8. Symbols palette
    9. Libraries
    10. Citations
    11. Scrapbook for clippings
    12. Bilingual dictionaries with translation service
    13. Projects, a way of co-ordinating your files across MsOffice software including Entourage to merge/create bulk email
    14. Templates for tables
    15. WordArt a way of altering text decoratively
    16. Autofit
    17. Macros
    18. Labels/Envelopes/Letter Wizzard/Pre-Printed
    19. Format Painter to copy apply formatting
    20. Inbuilt Sorting
    21. A Work Menu
    22. Multiple (customizable) Toolbars
    23. Much bigger and extendable Autotext feature
    24. Much bigger selection of Auto-shapes
    25. Line Numbering
    26. Much bigger and more flexible T.O.C.
    27. Much wider choice of Hyperlinking both within and between documents, email and web pages
    28. Much bigger selection of languages
    29. More flexible document protection
    30. Customizable keyboard
    31. Document tiling
    32. Audio notes
    33. Proofing tools
    34. Much bigger preference choices
    35. 3D objects
    36. Multiple Master pages
    37. Varied page orientation and sizes within the same document
    38. Ability to swap images
    39. Hyphenation control
    40. Open XML
    41. Automator support
    42. Wider range of document formats
    43. Greater compatibility with PC formats
    44. Direct link to user community
    45. Autosave/Recovery
    This was what a quick browse revealed. I suggest you try both sets of applications and explore, as I have done, for things that you find interesting.
    Peter

  • Best way to set up iPhoto; external drive

    HI!
    I want to set up iphoto in a way that steals less of my ssd drive space. I will buy a usb 3 harddrive, where I store my pictures. In iphoto I just want a reference to the picture on my external harddrive. But when working, some times I want to delete pictures; can I do this from iphoto, or will I only delete the reference?
    How do I make sure that I have no duplicates, when I store files this way?
    Ok, how do I set this up; is iphoto the best way?

    But when working, some times I want to delete pictures; can I do this from iphoto, or will I only delete the reference?
    It will only delete the Reference. iPhoto is not the best way. If you want to use iPhoto the best way is to run a Managed Library from the external disk.
    For more on iPhoto and file management see this User Tip:
    https://discussions.apple.com/docs/DOC-6361
    Aperture is much more powerful in this regard.

  • Looking for a best way to arrange an array of Pop Up windows with repeating small imgs

    I would like to find out what is the best way to approach setting up various Pop Up windows.
    Here is my set up:
    I have 20+ product images which act as buttons and each brings a user to a unique section with the pop up window where a large photo of this product in use is displayed. In addition to this photo in the pop up window are additional product images (which were also used to create a photographed assembly)
    I figured that since I repeat my product images on the pop up windows and all of them are already used in the product page let me use them again in the pop up window. So I arranged the pop up windows in each separate labeled section in which I reused the product images buttons from the products page and put the UI Loader into each separate labeled section which loads the big assebly photo of that product in use.
    Here are my questions:
    - Should each product have a separate labeled section with a pop up window
         This way I can reuse a number of already existing product button images and load only the high resolution assemble image
          However I end up having a lot of sections labeled for each product
    - or it should be arranged as follows:
         var sourceVar:String;
         function my_btnDown(event:MouseEvent):void {
         sourceVar="product_popups/product1_popUp.swf;
         gotoAndPlay("productsLoader");//where "productsLoader" is the labeled secion of my UI Loader
         This way I end up with one labeled section but have to implement up to 5 buttons on each new Pop Up.  In a sence I make the size of a loading pop up .swf a bit bigger by not recycling the existing buttons, but my assumption that I will have an easier funcitonality of the site?
    I am not sure which way would be a better or more appropriate way to go?

    Léonie-
    You are totally correct regarding custom tags instead of keywords depending upon the instance.
    My main point is that Folders are mostly misused. Images need to be keyworded or tagged and linked to Albums, generally not put in folders. With digital images almost always folder organization of images is just wrong, because folders by definition locate an image in just a single category. And few images are ever just in a single category.
    Some usage of folders can be helpful. Folders of Projects (e.g. 2001 Projects, Client royalfrenchel, etc.) make sense to help collapse a large number of Projects. However note that even in that simple two-folder example images cannot be in both folders at the same time without splitting the folders up.
    IMO users should spend  time carefully establishing how to keyword/tag and aggressively avoid using folders as much as possible. Eg. in Arturo's instance "week5" should be a keyword, not a folder. That way if one wants to make a brochure and use 5-week-old puppy pix it is an easy search on "week5" to retrieve pix to create an Album to peruse for brochure purposes. If "week5" instead comprises multiple deeply nested Folders subset to every litter of every Dam the process of retrieving becomes a nightmare.
    I welcome further discussion of this important topic.
    -Allen

Maybe you are looking for