Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:00,768 --> 00:00:03,072
Next important function is random function
1
2
00:00:03,584 --> 00:00:07,936
Random function will help you generate a random number between 0 and 1
2
3
00:00:08,448 --> 00:00:09,984
Zero will be included
3
4
00:00:10,240 --> 00:00:14,336
And one will be excluded what this mean is whenever you are finding a random number
4
5
00:00:14,848 --> 00:00:18,688
Zero is a possibility zero can come but one will never come
5
6
00:00:20,992 --> 00:00:24,832
Random is the function which will give you a random number between 0 and 1
6
7
00:00:26,880 --> 00:00:28,160
But many times
7
8
00:00:28,928 --> 00:00:30,464
The random number that you want
8
9
00:00:30,720 --> 00:00:32,768
Is not in the range of 0 and 1
9
10
00:00:33,024 --> 00:00:34,560
You have different ranges
10
11
00:00:34,816 --> 00:00:36,864
Of which you want a random number so
11
12
00:00:37,120 --> 00:00:40,960
Probably you need a random number between 0 and 100 or
12
13
00:00:41,216 --> 00:00:42,752
Say 10 and 20
13
14
00:00:43,008 --> 00:00:47,616
If you want a random number between say 10 and 20 how do you get that
14
15
00:00:48,640 --> 00:00:54,528
If you want a decimal random number, that is the random number that will be generated can have decimal values
15
16
00:00:55,552 --> 00:00:56,832
You can write this query
16
17
00:00:57,088 --> 00:00:59,392
Saying select random
17
18
00:00:59,648 --> 00:01:02,208
So this random will give you a value between 0 and 1
18
19
00:01:02,464 --> 00:01:07,840
You will multiply this value with the range so if it is 10 to 20
19
20
00:01:08,096 --> 00:01:09,632
So it will be 20-10
20
21
00:01:10,400 --> 00:01:12,448
So you multiply that random number with 10
21
22
00:01:12,704 --> 00:01:13,984
and you add the
22
23
00:01:14,240 --> 00:01:15,008
Lower
23
24
00:01:15,264 --> 00:01:18,080
Value of the range so 10 is the lower range
24
25
00:01:18,592 --> 00:01:19,616
so you add 10
25
26
00:01:20,640 --> 00:01:22,176
So it will become random
26
27
00:01:22,688 --> 00:01:23,456
Into *
27
28
00:01:23,968 --> 00:01:25,248
10 + 10
28
29
00:01:26,784 --> 00:01:28,064
This will give you a
29
30
00:01:28,320 --> 00:01:33,696
Random number which will have decimal places most probably between 10 and 20
30
31
00:01:35,232 --> 00:01:36,768
10 can occur
31
32
00:01:37,024 --> 00:01:42,656
Because random value can have zero value so this can give you an output of 10
32
33
00:01:42,912 --> 00:01:43,424
But
33
34
00:01:43,680 --> 00:01:45,216
20 will never occur
34
35
00:01:45,984 --> 00:01:48,800
20 will be excluded if you use this formula
35
36
00:01:50,848 --> 00:01:53,664
Now suppose you want an integer value only
36
37
00:01:54,688 --> 00:01:57,760
So how to get integer values from decimal
37
38
00:01:58,016 --> 00:02:00,832
Just few minutes back we learnt the ceil and floor function
38
39
00:02:01,600 --> 00:02:03,904
You can use the floor function here
39
40
00:02:04,160 --> 00:02:05,952
To convert that decimal value
40
41
00:02:06,208 --> 00:02:06,976
into
41
42
00:02:07,232 --> 00:02:08,512
a Integer value
42
43
00:02:08,768 --> 00:02:11,584
So, we multiply the random function
43
44
00:02:11,840 --> 00:02:16,448
With (b - a + 1) this will ensure that
44
45
00:02:16,704 --> 00:02:18,496
It is more than a
45
46
00:02:19,520 --> 00:02:22,336
This product will give you value
46
47
00:02:22,592 --> 00:02:23,616
More than one
47
48
00:02:23,872 --> 00:02:24,384
So that
48
49
00:02:24,640 --> 00:02:26,944
The lower value is more than a
49
50
00:02:27,968 --> 00:02:28,480
+ a
50
51
00:02:29,504 --> 00:02:30,528
So that will be lower range
51
52
00:02:32,320 --> 00:02:34,112
So let us go and find out
52
53
00:02:34,880 --> 00:02:37,696
a Random number between 10 and 50
53
54
00:02:38,208 --> 00:02:40,256
First we will do the decimal part
54
55
00:02:44,096 --> 00:02:46,656
So will be finding
55
56
00:02:47,168 --> 00:02:52,288
Random numbers between the range of 10 and 50
56
57
00:02:54,336 --> 00:02:57,408
The Range is
57
58
00:02:57,664 --> 00:02:58,944
a is equal to 10
58
59
00:02:59,200 --> 00:03:02,272
And b is equal to 50
59
60
00:03:08,928 --> 00:03:12,256
So let's write select
60
61
00:03:13,792 --> 00:03:17,376
First let us find a random number between 0 and 1 so random
61
62
00:03:19,936 --> 00:03:24,032
This will give a random number between 0 and 1comma
62
63
00:03:25,312 --> 00:03:30,432
Now let us find the decimal random number between 10 and 50 so the formula goes as
63
64
00:03:30,688 --> 00:03:34,016
Random
64
65
00:03:35,040 --> 00:03:36,576
Into
65
66
00:03:36,832 --> 00:03:37,344
40
66
67
00:03:39,392 --> 00:03:45,280
Why 40 because you have to multiply it with b-a
67
68
00:03:45,536 --> 00:03:47,328
We have multiplied it with 40
68
69
00:03:47,840 --> 00:03:48,608
then you add
69
70
00:03:49,120 --> 00:03:50,912
The lower range which is 10
70
71
00:03:52,704 --> 00:03:53,472
Next
71
72
00:03:53,728 --> 00:03:57,312
let us find out the integer value between
72
73
00:03:57,568 --> 00:03:58,592
10 and 50
73
74
00:03:59,616 --> 00:04:01,408
So we will write floor
74
75
00:04:02,176 --> 00:04:07,040
Within floors brackets we will write random
75
76
00:04:08,576 --> 00:04:11,136
So we will multiply it by 40
76
77
00:04:11,648 --> 00:04:12,160
+
77
78
00:04:12,672 --> 00:04:15,232
+ 10
78
79
00:04:17,024 --> 00:04:23,167
This will exclude the 50 value. If you want to include 50 you have to
79
80
00:04:23,423 --> 00:04:26,751
Add plus one here that will make it 41
80
81
00:04:27,007 --> 00:04:32,895
What we are doing right now if we are getting a value between 10 and 50 but the 50 is excluded
81
82
00:04:34,175 --> 00:04:38,271
So we will select these three values
82
83
00:04:38,527 --> 00:04:39,807
And we will run these
83
84
00:04:40,063 --> 00:04:45,439
So you will see the first column will have a value between 0 and 1
84
85
00:04:46,975 --> 00:04:50,815
The second column has a value between 10 and 50
85
86
00:04:51,071 --> 00:04:54,911
Third column has a value between 10 and 50 but it is an integer
86
87
00:04:55,935 --> 00:04:59,263
If you rerun this, all these three values will change
87
88
00:05:01,311 --> 00:05:03,871
Because that is what a random function is it will give you random values every time it is run
6778
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.