I think there might be something wrong with the test suite. When I run in Matlab, my answers match what the test suite is looking for, yet it still shows a failure.
Ben, your description suggests that rounding to 4 decimal places is optional. Perhaps you can clarify that. Test case with x = 365 is weird. The probability that no one shares a birthday for that x is close to 1.4550e-157 which is neglected during the rounding and hence highly probable event becomes a certainty !!
@Gary What you might be seeing is that the default output from Matlab is only 5 digits (generally). So you're probably seeing something like 0.0027 for X = 2 but if you multiply that answer by 1000 you will see there are still some digits trailing after the 7.
@Venu I think that's just an issue with how I did the calculation on my end. You're right that I should have it as 0.9999 in the test suite even though that is super close to 1 (the actual probability). I'll also make it clear in the brief that the answer should be out to 4 decimal points.
The problem should state truncate at the 10 thousandth point. n=50 is .97037 so the correct rounded answer is .9704 not .9703.
Instruction is to round, but correct answers are truncated (.9703 vs .9704)
I've used the function floor instead of round, because of the issue mentioned above and it worked.
It's very much possible that the target solution is wrongly rounded
Sums with Excluded Digits
Get the area codes from a list of phone numbers
Rotate a Matrix by 90 degrees
frame of the matrix
Find the treasures in MATLAB Central and discover how the community can help you!
Select a Web
Choose a web site to get translated content where available and see local events and
offers. Based on
your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country
sites are not optimized for visits from your location.
Contact your local office