After a relatively short delay, you’ll soon be able to enter the uniquely strange world of Death Stranding on Apple devices. Hideo Kojima’s walking simulator will be available on iPhone 15 Pro models and iPads and Macs with M-series chips on January 30. This version of the gloomy open-world adventure will run you $40. However, if you pre-order, you’ll save up to 50 percent.
Since this is the director’s cut of Death Stranding, it includes extras not available in the base game. Those include additional locations such as an underground factory, expanded story missions and more ways to help Sam Porter Bridge deliver packages, like a cargo launcher and a stabilizer to prevent the hero of the piece from falling over and losing some gear.
This article originally appeared on Engadget at https://www.engadget.com/death-stranding-is-coming-to-select-apple-devices-on-january-30-173544260.html?src=rss
Recently I’ve assisted with implementing some logic in Java that could easily be achieved with a single call of Numpy’s random.choice. It ended up being one of those tasks that allow looking into things you’re using every day but never have time to fully understand how they work. Also for quite some time I wanted to start learning Go, so why not kill two birds with one stone and reimplement random.choice once again this time in Go?
random.choice allows us to sample N elements from a provided collection according to the specified probabilities. Importantly (for the use case that motivated this work), it allows us to sample these elements without replacements. I.e. if an element of collection was already sampled it won’t be sampled again. For example, if we have a collection [A, B, C] with associated probabilities [0.1, 0.7, 0.2] and we want to sample 3 elements without replacements, most of the time we’ll get [B, C, A] as an output. If we sample with replacement, the expected output would be [B, B, B].
First, let’s define the signature of the Go function. We want to keep it as close to Numpy’s counterpart as possible.
A few things to notice about the function signature:
We’re using the generic type T. It allows calling this function for arrays of different types (as long as it satisfies the type constraint, which is none in our case). This should mimic the Pythonic semantics of random.choice, i.e. it doesn’t care about the type of elements stored in the input array.
We also pass the pointer to a random number generator (rng) object that we’ll use for sampling. I’ve picked up this style of defining random functions (compared to accessing the global instance of rng) from Jax. In my experience, it simplifies testing and reproducibility.
The function has two returns, one is the array of samples, and the second one of the type error . That’s the way to handle the “exception” execution flow in Go (Go doesn’t have assertions or exceptions).
Now we need to figure out how to sample elements from the discrete probability distribution defined by the probs argument using only float random numbers sampled uniformly between [0, 1] returned by the rng. Luckily there’s a method for doing exactly that.
CDF Inversion Method
First of, CDF stands for cumulative distribution function. In the discrete case, it can be represented as the array where an element at index i is equal to the sum of all input probabilities up to and including the position i. Let’s materialize this formulation in a simple helper function.
for i := range cdf { cum += probs[i] cdf[i] = cum }
return cdf }
With CDF of the discrete probability distribution and the random number generator, we can sample elements from the input collection by:
Sample a random float between [0, 1] from the Unirofrm distribution.
Find the first index where the CDF value is ≥ to the random float.
Return the element of the original collection at this index.
To understand why it works, we can do a simple visual experiment. We can think about values in the CDF array being the right borders of the bins placed on the interval between [0, 1]. The width of a bin is proportional to the input probability. When generating the uniform random float between [0, 1] we can think about randomly throwing the ball on the interval and choosing the bin that we hit. The probability of hitting the bin is then proportional to the input probability (exactly what we need). Here’s the visual demonstration for our last example of collection [A, B, C] with associated probabilities [0.1, 0.7, 0.2].
Created by the author in Excalidraw
To get the index of the bin we can return the index of the first right border that is greater or equal to the sampled value. Again, a simple helper function for doing exactly this:
func FindIndexFromRight(val float64, cdf []float64) int { for i, cumProb := range cdf { if cumProb >= val { return i } }
return len(cdf) - 1 }
Putting everything together
With that, we have everything to implement random.choice with repetitions. Sampling without repetitions requires one more trick. To ensure that we don’t draw the element that was already sampled, we can mask its probability with 0 after sampling. This, however, will invalidate our discrete probability distribution because its sum will no longer amount to 1. To correct for that we need to re-normalize the probabilities by dividing them by the new total sum. As a bonus, we can perform re-normalization directly on CDF instead of re-normalizing input probabilities and then computing CDF. Putting everything together:
func Choice[T any]( arr []T, size int, replace bool, probs []float64, rng *rand.Rand, ) ([]T, error) { if !replace && (size > len(arr)) { return nil, errors.New("cannot sample more than array size without replacements") }
If we sample without replacement we can’t sample more than the initial size of an input collection.
Go passes “slices” (arrays without defined size) as mutable arguments. Thus, we make a copy the of input probabilities for not to mess up the original array with masking.
Apple TV+ has been hit with a small round of layoffs as eight people who worked in kids content were let go on Tuesday.
Apple TV+
The cuts included music, production, and development for children’s programming. It is likely that the layoffs have come as Apple TV+ ended its contract with Skydance Animation, which happened in October.
According toDeadline, the fraction is pretty small compared to overall staff as the company remains dedicated to the genre. Apple TV+ has released more than 60 original kids titles since launch, and recently announced a raft of new children’s shows.
Children’s programming takes a hit as Apple TV+ lays off eight staffers
Originally appeared here:
Children’s programming takes a hit as Apple TV+ lays off eight staffers
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.